How can I deploy a matlab code that saves .mat files files to communicate between functions, and saves data in the local directory
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hamza Mahdi
am 14 Aug. 2017
Kommentiert: Walter Roberson
am 15 Aug. 2017
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 14 Aug. 2017
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.
Weitere Antworten (1)
Image Analyst
am 14 Aug. 2017
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 Kommentare
Siehe auch
Kategorien
Mehr zu MATLAB Compiler finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!