Attempt to reference field of non-structure array - the get command
2 ビュー (過去 30 日間)
古いコメントを表示
I'm programming a GUI created in GUIDE with MatLab2014, and upon a button-click a series of GET commands store information from the GUI (checkbox statuses, for the sake of fixing this error):
eeps_check = (get(handles.eeps_check,'val'));
tracefile_check = (get(handles.tracefile_check,'val'));
lambda_check = (get(handles.lambda_check,'val'));
now, I know the syntax of 'handles.eeps_check' must change somehow, as i get an error:
Attempt to reference field of non-structure array
MatLab is interpreting 'handles' as a struct, and 'eeps_check' as a field or something to that effect. This did not happen using MatLab2013.
So how should my syntax change such that i can store the information from checkboxes with handles 'eeps_check', 'Lambda_check', and 'tracefile_check' as variables in the workspace?? Thanks in advance.
3 件のコメント
Geoff Hayes
2014 年 8 月 28 日
No, if you are using GUIDE to design your GUI, then handles is typically an input variable/parameter to the majority of callbacks. It is a structure that manages all of the GUI-defined handles to individual widgets (push buttons, edit fields, list boxes, etc.) and it can also be used by the user to manage user-defined fields (like images, results of calculations, etc. that need to be shared between callbacks).
For example, if I create a simple GUI with a push button and a edit field, then the callback for the push button is
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Note the comment for the third input parameter. If I add some dummy code here and put a breakpoint at that line, I can then view what handles really is when the debugger pauses here
K>> handles
handles =
figure1: 185.00244140625
edit1: 8.0037841796875
pushbutton1: 186.00244140625
output: 185.00244140625
K>> class(handles)
ans =
struct
回答 (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!