Unable to locate and load .mat file after compiled into standalone file in App Designer

26 Ansichten (letzte 30 Tage)
Hello community and team,
I am new to app design and recently created an app using App Designer.
My app includes two additional files. The first one is a .mat file that contains a simFun (with no parallel turned on) and a doseTable. The second file is a class used to solve my equation.
The app runs flawlessly in the App Designer UI, but when I compile it into a standalone app, it always gets stuck at the simulation part. It seems that the compiled app cannot find and load the .mat file.
I have done some research on the isdeployed function, but none of the solutions I found could solve my problem and how could I locate the .mat file if I don’t know the path of the file in the app?
Interestingly, when I compiled the app on my MacBook Pro 15-inch 2016, it didn't work properly. However, when I used my friend's Mac mini 2021 M1, the compiled app worked without any issues. Both computers have MATLAB 2023a installed.
I have been frustrated as I couldn't solve this problem for a few days.
Could anyone provide me with some suggestions or advice regarding this situation?
Thank you very much.
Jesse

Akzeptierte Antwort

Arthur Goldsipe
Arthur Goldsipe am 7 Jun. 2023
I suspect the problem is that you need to include in your app additional supporting function files that are required by the SimFunction. You can see what files are needed by checking the DependentFiles property of the SimFunction. We also have an example of how to create a deployed application that uses a SimFunction here.
Here is some additional background: Whenever you create a SimFunction, one or more MATLAB function files are created and stored on the file system. When you first evaluate that SimFunction or call the accelerate method, MEX files are usually created as well. In a normal MATLAB session, these files are automatically created and added to the MATLAB path when you load a SimFunction object from a MAT file. However, in a deployed app, function files are not allowed to be added to the MATLAB path at runtime. So you must include these function files in the app when you create it.
I hope that fixes your problem. If you have any followup questions, let me know.
-Arthur
  3 Kommentare
Arthur Goldsipe
Arthur Goldsipe am 8 Jun. 2023
I'm not an expert on creating standalone applications, but let me see if I can help. If I can't answer your question, then it might be worth posting a new question specifically tagged as a question about the MATLAB Compiler.
Anyway, I think you have several options for getting information about the error. The easiest option might be to change the options of your deployed application so that it creates a log file that you can inspect. This page says it's an option under Additional Runtime Settings Options.
I have also lauched applications from the terminal on my Mac or from the Command Window within MATLAB, so that I can see output like error messages. When I create an app on the Mac, it also generates a shell script. For example, if I deploy MyApp.m, I can launch the deployed app MyApp.app by running run_MyApp.sh. Note that it needs one argument, which is the path to the root of your MATLAB or MCR installation. If I recall correctly, you don't get this shell script on Windows, but you can still launch the executable from a Command Window.
Jesse Chao
Jesse Chao am 8 Jun. 2023
Hello Arthur,
I just wanted to say that your suggestions are spot on and exactly what I needed.
I successfully ran the shell file for deuging on mac terminal.
I was able to first add permission to the shell file location by excuet the following code in mac terminal.
chmod 755 /shellfilefolderpath
As you said, I need to add matlab or mcr path as argument.
This could be simply done by type matlabroot in the matlab commmand line.
After this excuet the following code to run the shell file in mac terminal.
sudo sh /shellfilepath /matlabpath
I really appreciate you taking the time to help me out.
Your suggestions have been super helpful.
FYI, Windows does not have shell file as you said.
Thanks a bunch and have a great one!
Take care,
Jesse

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Communitys

Weitere Antworten in  SimBiology Community

Kategorien

Mehr zu Import Data finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by