how to manage radiobuttons?

조회 수: 2 (최근 30일)
Jihad Chamseddine
Jihad Chamseddine 2014년 7월 30일
댓글: Jihad Chamseddine 2014년 7월 31일
i have 2 radiobuttons, when i click on radio 1 and i then click on radio 2, radio 1 stays checked and thats not what i want, i want when one of the two radiobuttons are clicked the other should be unchecked immediately thanks

채택된 답변

Geoff Hayes
Geoff Hayes 2014년 7월 30일
Jihad - You can put the two (or more) radios buttons within a Button Group widget. Clicking on one radio button (within this widget) will automatically turn off the other (and vice versa).
  댓글 수: 3
Jihad Chamseddine
Jihad Chamseddine 2014년 7월 30일
also when i run the program, one radiobutton shows that is checked, but i want that when i run the program, neither of the 2 are checked so i can click the button that i want to be checked any idea?
Geoff Hayes
Geoff Hayes 2014년 7월 30일
From within GUIDE, go into the property inspector for both radio buttons and ensure that the Value field is set to 0.

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

추가 답변 (2개)

Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014년 7월 30일
Hi Jihad,
You can disable the one radio button as you clicked the other one.
Hopefully, you remember my previous assumptions and example
so do it like this
function radio_button1_Callback(hObject,eventdata,handles)
if get(handles.radio_button1,'Value')
set(handles.radio_button2,'Value',0)
end
  댓글 수: 2
Andrew Reibold
Andrew Reibold 2014년 7월 30일
I have used personally used the above method and it should work for you Jihad. Good luck.
Jihad Chamseddine
Jihad Chamseddine 2014년 7월 30일
ues this problem was solved, but now when i run the program, one of the 2 radiobuttons is checked automatically and what i want that the 2 radiobuttons should not be checked when running the gui

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


Salaheddin Hosseinzadeh
Salaheddin Hosseinzadeh 2014년 7월 30일
Hi Jihad!
Seems like we are just leading you to more problems!
There is a radio_bitton1_CreateFCN(hObject,eventdata,handles) function, which you can use to initialize your radio buttons. All you have to do is to go to this CreateFcn or CreateFCN function and type the as such
set(hObject,'Value',1); % if you want it to be seelcted initialy
set(hObject,'Value',0); % if you want it not be selected initially
regards.
  댓글 수: 1
Jihad Chamseddine
Jihad Chamseddine 2014년 7월 31일
thank you very much

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

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by