How can I deploy a matlab code that saves .mat files files to communicate between functions, and saves data in the local directory
5 次查看(过去 30 天)
显示 更早的评论
Hello, I wrote a GUI in matlab using GUIDE and I am using a data structure that is saved as a .mat file in the local directory of the matlab application. the .mat file is used to transfer variables between different functions in the GUI, for example, in the beginning of a function I would write
load data;
And I would have access to all the variables stored before. I am now trying to create a standalone application using the matlab compiler, however, the application does not seem to save the matrix in the local directory or any of the results in .mat format. Is there any workaround? I need the .mat functionality as I analyze videos and save each frame data in a seperate .mat file in a folder that I create in the local directory as well.
0 个评论
采纳的回答
Walter Roberson
2017-8-14
The file would be looked for in ctfroot() and saved there as well. See https://blogs.mathworks.com/loren/2008/08/11/path-management-in-deployed-applications/
When you create an executable that is launched graphically by an icon, the current directory for it is not going to be the current directory of the user: on windowed systems, the user does not have a "current" directory (or has several.)
The user might have a home directory that you can figure out by examining environment variables.
更多回答(1 个)
Image Analyst
2017-8-14
Use getdir() to ask the user where he wants to save the file. Or else save it in some known, predetermined folder. Don't save things in the current folder because it's very tricky to find out where that is in a compiled application. It's better to use a folder that you're sure about - a folder with a known location.
Then use fullfile() to create the full file name (folder + base file name + extension).
When compiling a standalone executable, never leave any filenames up to chance by using default values - you'll regret it.
2 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!