How can I deploy a matlab code that saves .mat files files to communicate between functions, and saves data in the local directory
Show older comments
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.
Accepted Answer
More Answers (1)
Image Analyst
on 14 Aug 2017
3 votes
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 Comments
Hamza Mahdi
on 15 Aug 2017
Walter Roberson
on 15 Aug 2017
I think Image Analyst meant to refer to uigetdir()
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!