Error Message: Undefined function, App Designer
16 ビュー (過去 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!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/784218/image.png)
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 で Graphics Object Programming についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!