Radiobutton control

5 次查看(过去 30 天)
Paraskevas Papanikolaou
I have six radio buttons and a pushbutton in my gui .I want depending on which radiobuttons are pressed by the user the gui to be able to plot different histograms.And if no radiobutton is pressed a message to appear and warn the user tha he should push a radio button .My code is this :
% --- Executes on button press in radiobutton12.
function radiobutton12_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton12
handles.radiobutton12=get(hObject,'Value');
guidata(hObject,handles)
...
and other 5 radiobuttons Callbacks ....and then the pushbutton :
% --- Executes on button press in pushbutton19.
function pushbutton19_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton19 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if (get(handles.radiobutton12 ,'Value') == get(handles.radiobutton12 ,'Min'))&& (get(handles.radiobutton13 ,'Value') == get(handles.radiobutton13 ,'Min'))&& (get(handles.radiobutton14 ,'Value') == get(handles.radiobutton14 ,'Min'))&& (get(handles.radiobutton15 ,'Value') == get(handles.radiobutton15 ,'Min'))&& (get(handles.radiobutton16 ,'Value') == get(handles.radiobutton16 ,'Min'))&& (get(handles.radiobutton17 ,'Value') == get(handles.radiobutton17 ,'Min'))
msgbox('You should select at least one radiobutton in order to evaluate the condition of the patient and see the histograms','Patient Progress','warn')
return
else
figure('Name','b value histograms ','NumberTitle','off');
kan=max(max(handles.hist),max(handles.hist1));
xlim([0 255])
plot(handles.hist/kan,'b');
h = legend('Before Treatment','Location','NorthEast');
set(h,'Interpreter','none')
xlabel('b-value Signal_Density');
ylabel('Volume Fraction of Tumor');
hold on
if handles.radiobutton12==1;
plot(handles.hist1/kan,'r');
h= legend(h,'After Treatment','Location','NorthEast');
set(h,'Interpreter','none')
end
...and it continues for each radiobutton press.
when i press the push button without any pressed radiobutton the warning message appears but when i push a radioutton matalb gives me this error ??? Error using ==> get There is no 'Value' property in the 'figure' class.
Error in ==> DWI_Liver_Analyzer>pushbutton19_Callback at 2388 if (get(handles.radiobutton12 ,'Value') == get(handles.radiobutton12 ,'Min'))&& (get(handles.radiobutton13 ,'Value') == get(handles.radiobutton13 ,'Min'))&& (get(handles.radiobutton14 ,'Value') == ge
What should i change can anybody help me ?
Thanks in advance .

回答(2 个)

Sean de Wolski
Sean de Wolski 2012-5-21
Run:
dbstop if error
And then run your program as you were. Reproduce the error and the debugger will stop on line 2388. On this line inspect each variable and each call to |get()}. It should be apparent at this point that one of the handles is actually to a figure trying to get its 'Value' property which it doesn't have.

Paraskevas Papanikolaou
Sean de Wolski , thank for your time but i dont think that that s the problem ,the beggining of the code in the i do this for all the radiobuttons,12,13 ,14,15,16,17 :
% --- Executes on button press in radiobutton12.
function radiobutton12_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton12
handles.radiobutton12=get(hObject,'Value');
guidata(hObject,handles)
how can a handle is going to a figure ?perhaps isnt this the right way to write the code .
the thing i want is if no radiobutton is pressed to show a message ,i know its quite simple but .....i am stuck!
Thanks again .....if you have other ideas please help !!!!!
  1 个评论
Sean de Wolski
Sean de Wolski 2012-5-21
Because this callback must be getting called by the figure.
Look at the figure's callbacks in ther GUIDE inspector.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by