Why am I getting a NaN value when calling a variable using uicontrol?
25 ビュー (過去 30 日間)
古いコメントを表示
Im building an app for work and at the end I want to have the average speed of a vehicle shown in a box after pressing run. I have speed data, and I took the average using this line of code:
AvgSpeed1 = mean(RealSpeed1);
Pretty simple. It should give me a value around 2.5. I have a couple uipanels, one of which is called panel2, and I created this block of code to generate the text after the run button is pressed:
avgSpeed = uicontrol(panel2, "Style", "text");
avgSpeed.Position = [10 50 200 20];
avgSpeed.FontSize = 10;
At the end of the run function I have this line of code to generate the text within the box:
avgSpeed.String = sprintf("Average Speed: %.3f", AvgSpeed1);
After pressing the run button I get this result:
As you can see the result I get for average speed is NaN, but I have this exact setup for a few other variables like final run time and the time taken to process the data without issue. The code for these other two is exactly the same as the average speed. What im confused about is why im getting a NaN value, I checked the data within my vairables and do not have any NaN values, so im wondering if im missing any syntax or if Im doing this incorrectly. Any help is appreciated. Thanks!
0 件のコメント
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!