Where are the variables in App Designer stored and how can I view them.
201 views (last 30 days)
Show older comments
Thomas McNEil
on 18 May 2018
Edited: Vasilisa Iatckova
on 6 Sep 2022
I have an app that I am using to display a large data file. I am selecting a column of data from that file using a listbox and then would like to display that data on a plot. I use a global variable to hold the Structure (U), then get the field names using fieldnames(app.U). The field names fill a listbox, which the user can then select the particular field they want to display in the plot. Then I fill another array with just the values from that field using value = app.DataListBox.Value; app.MyValues= getfield(app.U,(value));
I have a pushbutton I want to use to then display the data on UIAxes.
% Button pushed function: PlotButton function PlotButtonPushed(app, event)
plot(app.UIAxes, app.MyValues)
end
When I run the app, I can open the file-select the field I want to display and then push the Plot Button, nothing shows up in the plot. I don't know if the array app.MyValues is being filled. In MATLAB there is a workspace window I can see my variables, where are they viewable in Appdesigner for debug? Is there a workspace window in Appdesigner that shows the current values of the global properties?
2 Comments
Eric Sargent
on 9 Dec 2020
Edited: Eric Sargent
on 9 Dec 2020
You don't need to define global variables, you need to define properties within the app.
https://www.mathworks.com/help/matlab/creating_guis/share-data-across-callbacks-in-app-designer.html
You can then access those app properties (which you can think of as global variables) by calling "app.<property>" in other functions / callbacks within the app. This will greatly simplify your code and ability to debug it.
jiansong wan
on 29 Jul 2022
I'm using Matlab R2018a, after running my app, my workspace is empty and I cannot find any 'app' struct or variables. IS this a bug? Is there a workaround? Thanks!
Accepted Answer
Ameer Hamza
on 18 May 2018
Edited: Ameer Hamza
on 18 May 2018
You can put a breakpoint in your app designer function similar to MATLAB function point by clicking the (-) next to the line number. When the execution will reach the breakpoint, the app will stop and all the app variables will appear in workspace window. You can check their values in Command window and debug your app.
6 Comments
Steven Lord
on 26 May 2022
Did you define a method or property in your app named properties? If so rename that method or property so MATLAB can call the properties function included as part of MATLAB.
Gary Burton-Wilcock
on 9 Jun 2022
Edited: Gary Burton-Wilcock
on 9 Jun 2022
No, no porperty or method called 'properties'. I just used that as a general term. Here is a very simple app that shows the problem. If I put a breakpoint on line 22 the app.temporary variable has been set. However I can't see it in the workspace. I can see 'app' but if I try to open it my PC pings as if an error has been generated. See second pic.
Workspace
I cannot see any of the properties within the app. This IS NOT how it used to behave and is not very helpful.
More Answers (2)
Orion Miller
on 14 Aug 2019
All the app properties are in the workspace the same way as the local variables when you insert a breakpoint within the function. You have to just click on "app" because they're all nested within app
1 Comment
Evan Weststrate
on 24 Oct 2019
this used to work.. But now (R 2019b) when you click on 'app' in the workspace while at a breakpoint, it no longer opens it up in the Variables window, it just brings up the "Property Inspector" which is kindof useless if you want to know what an app property value is at that time.
Annoying workaround: in the command window type:
myVar = app.myVar
and then look at what myVar is.
Vasilisa Iatckova
on 4 May 2022
Edited: Vasilisa Iatckova
on 6 Sep 2022
You can also call an instance of your app from another instance of matlab (you have to run your app with the latest edits first, I believe), as in
app = MyApp
and the app handle will give you full access to your app. You can use this to try out different things before coding them into your callbacks (you can modify or query for any property). For events, you can assign a copy to e.g. UIFigure.UserData within the callback that you want to see the event for.
keyboard command will interrupt app execution and allow you to operate on the environment up to that point in the instance from which you called the app designer window.
0 Comments
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!