Error Message: Undefined function, App Designer

19 views (last 30 days)
Hello,
this is the code I am using in order to first display data in a table, and then I would like to plot two columns of that table when I press another button (time and power).
I get the error message that the function "time" is not defined, eventhough in the callback for loading the data, I have defined time as a double array. What to do?
When I copy the above code and reenter it before the plot command, the table loads as NaN.
Thank you for your help!

Answers (1)

Alamanda Ponappa Poovaya
Alamanda Ponappa Poovaya on 2 Nov 2021
Edited: Alamanda Ponappa Poovaya on 2 Nov 2021
The reason this error is occuring is that, while you have created both time and power variables, they are at the moment local to the function you have created them in. Other functions do not have access to these variables.
In order to resolve this, you should add properties using the option in the toolstrip, and access these properties using app.propertyName
In your case, you would need to add properties named time and power, and set them as
app.time = str2double(Time);
app.power = str2double(Power);
I would also suggest you create another property for value, in the VonDatePicker function
Refer to the documentation below wheich elaborates on how to share data within your App designer app
As for the table showing NaN, this is because of str2double, which will return NaN when the input is not a valid number. Since you are dealing with time, I would suggest you check out the datetime function to do your time conversion
You can then refer to https://www.mathworks.com/help/matlab/matlab_prog/plot-dates-and-durations.html which will guide you in using datetime to plot on a graph
Hope this helps

Categories

Find more on Graphics Object Properties 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!