MATLAB: How to access and interact with the variables loaded in the App

accessappappdesignercallbackdesignerfunctionguiguideinteractloadvariablesworkspace

When I run my App, I don’t see a MATLAB interpreter workspace where I can directly interact with the variables loaded in the app. Is there a way to pull those variables in an interactive manner while the app is running (for example, access the string of some static text)?

Best Answer

MATLAB does not have a separate workspace that stores all of the variables loaded in your app. Rather, there is a base workspace in MATLAB, which contains variables loaded from the command line or created by scripts you run, a global workspace for variables declared as global, and there are unique workspaces for each function, which contain their local variables. Local variables defined in a function workspace will be automatically cleared from memory when the function returns.
Base and Function Workspaces:
Variables created or loaded within the functions of your GUI would be stored in a specific function's workspace, not the base workspace. To view the workspace of a specific function, you can place a breakpoint inside that function before running your app. Then, when you run the app, it will stop when it gets to the breakpoint, and you will be able to see and interact with the variables of that function from the Workspace Browser on the MATLAB Desktop.
You can also use various strategies to share data among different functions of your app, if you do not wish this data to be cleared from memory when a function ends.
Share Data Among Callbacks: