Error Message: Undefined function, App Designer
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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!
0 commentaires
Réponses (1)
Drishan Poovaya
le 2 Nov 2021
Modifié(e) : Drishan Poovaya
le 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
https://www.mathworks.com/help/matlab/creating_guis/share-data-across-callbacks-in-app-designer.html
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
0 commentaires
Voir également
Catégories
En savoir plus sur Develop Apps Using App Designer dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!