Accessing data from Radio Buttons
이전 댓글 표시
Hello,
perhaps this is a better way to phrase my question. I have a group of radio buttons within a panel. I need to know which one is selected to use in simple "If/Then" statements
If (this radio button is selected && this menu item is clicked) Execute this
I am using the code from an online example
I am trying
get(handles.radiobutton1, 'Value')
to access what it is but no matter which button of the four I have selected all handles are apprearing as zero.
Thank you
채택된 답변
추가 답변 (2개)
Fangjun Jiang
2011년 6월 29일
3 개 추천
Bill, let's work out this "button group" issue first. Your code in previous post is overly complicated.
Start with a new GUI, drag and drop a "button group", drag and drop 4 radio buttons inside the "button group" panel.
In the SelectionChangeFcn callback of the "button group", type in the following single line.
disp(get(hObject,'Tag'));
Then run your GUI and click different buttons, see what happened in the command window. That's how it works.
Walter Roberson
2011년 6월 29일
1 개 추천
Get the SelectedObject property of the uibuttongroup, and get() the Tag of that object (having set the tags uniquely when you created the buttons.)
Note: in previous postings, people indicated that one of the buttons must be selected; that is incorrect. You can have nothing selected by setting the SelectedObject property to []
카테고리
도움말 센터 및 File Exchange에서 App Building에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!