Problem with Undefined variable or class

7 ビュー (過去 30 日間)
Damian
Damian 2018 年 1 月 26 日
コメント済み: Stephen23 2018 年 1 月 29 日
Matlab can't see defined struct variable. And I inform you that i had connection with Robot in that time. I apologize for so many posts from me i'm not that good at programming. P1 = rpoint(kwadrat_zolty.Centroid_x*kalibracja,kwadrat_zolty.Centroid_y*kalibracja,-15.600,0,0,0,'signal',[9,-10],'pulse',[1 0.5],'wait',5); % pobranie
If someone don't know what is rpoint I wrote about it here: https://www.mathworks.com/matlabcentral/answers/378570-how-to-get-data-values-from-struct-and-save-it-in-struct?s_tid=prof_contriblnk

採用された回答

Guillaume
Guillaume 2018 年 1 月 26 日
The variable exists in your workspace, but the error is telling you that in the callback function it does not exist. Functions have their own workspace and if you don't pass them the variables explicitly they can't access them.
Without seeing the callback code and the line where you call that callback it's difficult to tell you how to fix it.
  2 件のコメント
Damian
Damian 2018 年 1 月 26 日
編集済み: Damian 2018 年 1 月 26 日
Ok i repaired it. I had to use one more time
evalin('base',' ');
for my "invisible" missing structure to this callback button. Thanks.
Stephen23
Stephen23 2018 年 1 月 29 日
Rather than using inefficient and buggy methods of passing data between callbacks and workspaces (e.g. evalin and assignin), you would be much better off using better (simpler, more efficient, easier to debug) methods, such as guidata or nested functions. Read more in the MATLAB documentation:
And also read why magically throwing data into other workspaces (e.g. evalin or assignin) is not recommended (unless you want to write slow, buggy, complex code that is hard to debug):

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by