MATLAB: Running script from App designer, workspace not updated

app designerMATLABscriptvariablesworkspace

Hello,
I am trying to run a script from App designer. This script defines variables based on files in a folder., the files are timeseries and it can vary how many files which are in the folder. When I run this script from the command window, all the variables are found in the Workspace afterwards. This is not the case when running it from the App designer. In the application there are other scripts depending on the variables from this script, hence if the variables exsisted in the workspace this would be an advantage. Due to the variation in the folder, I think it would be unwise to make a fixed number of outputs and converting the script into a function. Please let me know if you have any tips or ideas how I can make this work.
Thank you very much in advance.

Best Answer

If you are trying to view these just so you know they are being shows correctly, then you can enter debugging mode (very similar to debugging in a livescript) by clicking the '-' (on the left hand side of the code view) next to the line number directly after the line of code you are querying. This pauses the app code and all variables within the current function are displayed in the workspace.
If you are wanting to use these variables within Matlab (not App designer), then you can use the following at the top of the function within the app which contains what you want:
global ThingYouWant
% Replace 'ThingYouWant' with whatever variable you need to display.
Then you simply go to your command window, type exactly what you put in the app and the variable should show up in the workspace.
Let me know of any problems and I'll try my best to help.