필터 지우기
필터 지우기

How to know if a radio button is selected or not?

조회 수: 10 (최근 30일)
Meshooo
Meshooo 2014년 3월 20일
댓글: Meshooo 2014년 3월 20일
Dear all,
I have one GUI with 4 Radio Buttons and one Push Putton. All of them are in one Button Group.
I want, if the user didn't select any radio button, then the Push Button will do code-A, and if the user selected any of the radio buttons, then the Push Button will do code-B.
Any idea how to do that?
The code below is in my Push Button Function
if
%user did not select any radio button, then do this
else
%do this if a user selected a radio button
switch get(get(handles.uipanel4,'SelectedObject'),'Tag')
case 'radiobutton5', line_type = 'imline';
case 'radiobutton6', line_type = 'impoint';
case 'radiobutton7', line_type = 'imfreehand';
case 'radiobutton8', line_type = 'impoly';
end
Any suggestion will be appreciated.
Thank you.
Meshoo
  댓글 수: 1
nl2605
nl2605 2014년 3월 20일
The pushbutton is also in the button group?

댓글을 달려면 로그인하십시오.

채택된 답변

nl2605
nl2605 2014년 3월 20일
Anyway what you can do is in the callback function of your pushbutton, write this if else statement
if (get(handles.radiobutton1,'Value') == 0 && get(handles.radiobutton2,'Value') == 0 && get(handles.radiobutton3,'Value') == 0 && get(handles.radiobutton4,'Value' == 0)
%user did not select any radio button, then do this
else
%do this if a user selected a radio button
switch get(get(handles.uipanel4,'SelectedObject'),'Tag')
case 'radiobutton5', line_type = 'imline';
case 'radiobutton6', line_type = 'impoint';
case 'radiobutton7', line_type = 'imfreehand';
case 'radiobutton8', line_type = 'impoly';
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Analog Devices ADALM1000 Support from Data Acquisition Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by