Error Message: Undefined function, App Designer
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Drishan Poovaya
2021-11-2
编辑:Drishan Poovaya
2021-11-2
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 个评论
另请参阅
类别
在 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!