MATLAB Answers

0

Where are the variables in App Designer stored and how can I view them.

Asked by Thomas McNEil on 18 May 2018
Latest activity Commented on by Thomas McNEil on 22 May 2018

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?

  0 Comments

Sign in to comment.

Products


Release

R2017b

1 Answer

Answer by Ameer Hamza
on 18 May 2018
Edited by Ameer Hamza
on 18 May 2018
 Accepted Answer

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.

  3 Comments

I did what you said, and the code stopped, but the only variable which showed up was in the command window and it was a local variable I used to hold field names. %get the field names fieldNames = fieldnames(app.U) app.DataListBox.Items = fieldNames;

So fieldNames shows up, and the list of field in the command window. But no variables with the app.* prefix are showing up and there is nothing in Matlabs Workspace window (where normally all the variables would be listed).

This will display the function workspace. Does your function, in which you are adding the breakpoint have app in its list of arguments? For example like this

function ButtonPushed(app, event)

app is the first argument. If this is the case, app variable should appear in the workspace window. Note that the breakpoint should be added inside the body of app function, not in the body of an external function you are calling in your app.

So I am able now to see the variables in the workspace window using breakpoints. I can only see variables local to the function that they are inside though. Any of the global app.* variables remain unseen so I copy them to a new variable inside the local one and watch them from there. Thanks for your help

Sign in to comment.