How can I deploy a matlab code that saves .mat files files to communicate between functions, and saves data in the local directory
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hamza Mahdi
el 14 de Ag. de 2017
Comentada: Walter Roberson
el 15 de Ag. de 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 comentarios
Respuesta aceptada
Walter Roberson
el 14 de Ag. de 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.
Más respuestas (1)
Image Analyst
el 14 de Ag. de 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 comentarios
Ver también
Categorías
Más información sobre MATLAB Compiler en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!