Crash course on GUI's starts... now:
If you're using guide
, then when you save your figure mygui.fig, the M-file should be automatically generated as mygui.m. Open up mygui.m and enter your code under the radio button callback function. Any variables that you want initialized when you start the program should be defined under the opening function. Make sure you update the handles structure at the end of each callback, with the command guidata(hObject,handles).
For example, if you wanted two mutually exclusive radio buttons (when you select one, the other de-selects, or when you de-select one, the other is selected), enter the following code under their callbacks:
function radiobutton1_Callback(hObject, eventdata, handles)
if get(handles.hObject,'Value')
set(handles.radiobutton2,'Value',0)
else
set(handles.radiobutton2,'Value',1)
end
guidata(hObject,handles);
and
function radiobutton2_Callback(hObject, eventdata, handles)
if get(hObject,'Value')
set(handles.radiobutton1,'Value',0)
else
set(handles.radiobutton1,'Value',1)
end
guidata(hObject,handles);
And initialize radio button one to be selected under the opening function:
set(handles.radiobutton1,'Value',1)
set(handles.radiobutton2,'Value',0)