Unable to locate and load .mat file after compiled into standalone file in App Designer
19 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Arthur Goldsipe
2023-6-7
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 个评论
Arthur Goldsipe
2023-6-8
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.
更多回答(0 个)
社区
更多回答在 SimBiology Community
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Import Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!