Attempt to reference field of non-structure array

I am using GUIDE to create a nifty tool. Originally I would open the ".fig" file in GUIDE, as you right-click it. Then run the program from there. Today I decided to 'OPEN' it directly when I right-click the ".fig" file. Here is the error:
??? Attempt to reference field of non-structure array.
Error in ==> Cable_Sizing_Rev3>choose_resistance_data_source_popup_Callback at 1569
relevant_handles = [ handles.resistivity_edit, handles.resistivity_text, handles.unit_resistivity_text, ...
Error in ==> gui_mainfcn at 96
feval(varargin{:});
Error in ==> Cable_Sizing_Rev3 at 53
gui_mainfcn(gui_State, varargin{:});
Error in ==>
@(hObject,eventdata)Cable_Sizing_Rev3('choose_resistance_data_source_popup_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback
I have checked other soluctions and it didn't quite help solve the problem.

 採用された回答

Image Analyst
Image Analyst 2014 年 1 月 9 日
編集済み: Image Analyst 2014 年 1 月 9 日

0 投票

You are referencing three fields of handles: resistivity_edit, resistivity_text, and unit_resistivity_text. handles does not have at least one of those fields . Put handles with no semicolon right before you call the line:
handles
relevant_handles = [ handles.resistivity_edit, ............
That will cause all the fields of handles to be sent to the command window so you can determine which one field is missing.
EDIT: On second thought, you can't run the fig file from the current folder panel like you tried. You have to either type F5 or click the green triangle if you're in the editor, or click the green triangle in GUIDE. That's why handles is undefined.

1 件のコメント

tuyen
tuyen 2014 年 1 月 14 日
Thanks for your time to answer this. I will compile this into .exe file very soon.

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

その他の回答 (1 件)

Matt J
Matt J 2014 年 1 月 8 日

1 投票

Doesn't sound like a problem. The initial way you were running the GUI is the right one. You can also run the mfile that GUIDE produces to launch the GUI.

6 件のコメント

tuyen
tuyen 2014 年 1 月 9 日
Do you think that by opening ".fig" file directly, doesn't read (if thats the correct term) the OpeningFcn section of the m-file? Unless I misunderstood the difference of how MatLab initializes the run process of GUI. Thanks
Matt J
Matt J 2014 年 1 月 9 日
編集済み: Matt J 2014 年 1 月 9 日
Yes. The primary execution functionality of the GUI is managed by the mfile, not the .fig file, so launching the latter doesn't do much. When you launch the GUI from the GUIDE toolbar, it is basically invoking the mfile as well.
tuyen
tuyen 2014 年 1 月 9 日
Very good, thanks very much for your input and support, I really am. I am still curious to why my other GUI's did not have the same error of "Attempt to reference field of non-structure array." I will dig into this when there is time, even though opening it directly have the errors, while it still functions by opening through Mfile or GUIDE.
Matt J
Matt J 2014 年 1 月 9 日
編集済み: Matt J 2014 年 1 月 9 日
Are you sure the above errors are generated immediately just by opening the .fig? Or, is it possible that you opened the .fig and then started pressing buttons and uicontrols? I can imagine the later triggering the errors you see. Your callbacks would then be launched without the gui's data first being properly initialized by your OpeningFcn.
tuyen
tuyen 2014 年 1 月 14 日
That is correct, it does not show the error immediately, only when I make this one particular selection. Does make sense to have it run (green play button) from the Mfile or GUI figure first. Thanks J.
tuyen
tuyen 2014 年 1 月 14 日
Wow, I can't accept TWO answers?! I am sorry Matt J., you definitely deserve a reputation as well.

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

カテゴリ

ヘルプ センター および File ExchangePrinting and Saving についてさらに検索

質問済み:

2014 年 1 月 8 日

コメント済み:

2014 年 1 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by