MATLAB: Appdesigner: Loading values into the standard Matlab Workspace and utilsing them

appdesignerm-code

I have a piece of m code that works nicely from Matlab – it loads a long list of parameters into the workspace, performs some calculations and then produces some helpful plots.
But when I try to run the same m code from within Appdesigner, none of my parameters are loaded into the Matlab Workspace, even though the code is unchanged in any way.
Can one of you wonderful people offer any suggestions, please ? Thank you in anticipation of your helpful reply.

Best Answer

If you load the data into the App, it will not appear in the MATLAB base workspace. MATLAB functions or app functions have their own workspaces. So the data loaded inside the function will not be visible in the workspace window unless you are in debugging mode. To correctly load the data and share it in app callback functions you need to do the following.
1) Load the data inside the startUpFcn of the app as shown here. In other words, paste your script inside this function. This function executes everytime you start the app.
2) Then to share the data between app callback functions, refer here. You can create properties, assign the loaded data to these properties in startUpFcn and then other callbacks functions inside your app can access the data using the properties.