Hello, I want to make a simple GUI. I have two Radiobuttons in an UIpanel. Additionally a pushbutton . After pushing the Button a Messagebox shall appear , depending on the choice of the radiobuttons .
this is my Code. first I proof, which Button is selected and save this
function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)if hObject == handles.radiobutton1 setappdata(handles.radiobutton1,'a',1) setappdata(handles.radiobutton2,'b',0)elseif hObject == handles.radiobutton2 setappdata(handles.radiobutton1,'a',0) setappdata(handles.radiobutton2,'b',1)end
Depois I get the savefile and make an msgbox, depending on the radiobutton
function pushbutton1_Callback(hObject, eventdata, handles)a=getappdata(handles.radiobutton1,'a');b=getappdata(handles.radiobutton2,'b');if a==1 msgbox ('first button')else if b==1 msgbox('second button') endend
keep running the .m file. Everything is great, but if I start the programm, from the command window I recieve this error.
Attempt to reference field of non-structure array.
- Error in
- untitled>uipanel1_SelectionChangeFcn
- (line 105)
- if hObject == handles.radiobutton1
- Error in gui_mainfcn (line 96)
- feval(varargin{:});
- Error in untitled (line 42)
- gui_mainfcn(gui_State, varargin{:});
- Error in
- @(hObject,eventdata)untitled('uipanel1_SelectionChangeFcn',get(hObject,'SelectedObject'),eventdata,guidata(get(hObject,'SelectedObject')))
- Error in hgfeval (line 63)
- feval(fcn{1},varargin{:},fcn{2:end});
- Error in
- uitools.uibuttongroup/childAddedCbk>manageButtons
- (line 79)
- hgfeval(cbk, source, evdata);
- Error while evaluating uicontrol Callback
I hope someone could help me
Best Answer