フィルターのクリア

error: refernce to non existent field (handles) GUI

1 回表示 (過去 30 日間)
Preshma Linet Pereira
Preshma Linet Pereira 2015 年 3 月 26 日
回答済み: Image Analyst 2015 年 3 月 29 日
hey i am just a beginner so please help my silly question too. i have two radio buttons in my gui and i want to know which one is selected i found a code online but the variable in which i store the value remain local to that 'selectionChange' function
function image_type_SelectionChangeFcn(hObject, eventdata)
handles= guidata(hObject);
switch get(eventdata.NewValue, 'Tag' )
case 'rgbbutton'
handles.im='RGB';
case 'grayscalebutton'
handles.im='grayscale';
end
disp(handles.im);
guidata(hObject,handles);
and hence when i call 'handles.im' in function 'Combine_callback' it gives the error below
reference to non-existent field 'im'
the combine_callback code is as follows
function combine_Callback(hObject, eventdata, handles)
handles=guidata(hObject);
im=handles.im;
disp(im);
please help. this is my project and i need to execute it!
  1 件のコメント
Geoff Hayes
Geoff Hayes 2015 年 3 月 29 日
Preshma - are you sure that the image_type_SelectionChangeFcn is being called and that the handles.im is being set? I placed your above code in a simple GUI and it did work. When you created the two radio buttons, did you put them in a Button Group panel?

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

回答 (1 件)

Image Analyst
Image Analyst 2015 年 3 月 29 日
Don't call guidata immediately. Try this:
function image_type_SelectionChangeFcn(hObject, eventdata)
radio1 = get(handles.rgbbutton, 'Value');
radio2 = get(handles.grayscalebutton, 'Value');
if radio1
handles.im='RGB';
elseif radio2
handles.im='grayscale';
else
% Should not get this case, but just for robustness...
handles.im = 'Unknown';
end
disp(handles.im);
guidata(hObject,handles);

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by