MATLAB: How to deploy a matlab code that saves .mat files files to communicate between functions, and saves data in the local directory

guideMATLAB Compilerstandalone

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.

Best Answer

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.