Where are the variables in App Designer stored and how can I view them.
213 次查看(过去 30 天)
显示 更早的评论
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 个评论
Eric Sargent
2020-12-9
编辑:Eric Sargent
2020-12-9
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
2022-7-29
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!
采纳的回答
Ameer Hamza
2018-5-18
编辑:Ameer Hamza
2018-5-18
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 个评论
Steven Lord
2022-5-26
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
2022-6-9
编辑:Gary Burton-Wilcock
2022-6-9
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.
更多回答(2 个)
Orion Miller
2019-8-14
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 个评论
Evan Weststrate
2019-10-24
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
2022-5-4
编辑:Vasilisa Iatckova
2022-9-6
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!