store value of selected radio button from group button
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Share a link to this question
i want get the value of selected radio button from button group i use this code:
u=get(handles.uipanel12,'SelectedObject');
but this code get me a number while the object is a string.(name and tag of radio button)
can u help me?
thanks
Accepted Answer
Walter Roberson
on 21 Dec 2013
Edited: Walter Roberson
on 21 Dec 2013
u = get(get(handles.uipanel12,'SelectedObject'), 'Value');
7 Comments
fatemeh
on 21 Dec 2013
thanks very much!
Image Analyst
on 22 Dec 2013
Wouldn't this always be true? I mean, if it's the selected radio button in a group of radio buttons, its value is true. How could it be anything else? Selecting it means that you're setting it true, by definition.
Jean Sebastien Louis
on 30 Mar 2016
Yes, you have simply to select the property you want (i.e. 'Value', 'Tag' etc..) If you want the Tag of the radiobutton selected you should do so:
u = get(get(handles.uipanel12,'SelectedObject'), 'Tag');
praveen chandaliya
on 8 Sep 2017
Edited: Walter Roberson
on 8 Sep 2017
Walter Roberson
by default one radio button is selected in button group but i want initial no radio button selected with Buttongroup
Walter Roberson
on 8 Sep 2017
praveen chandaliya : That does not appear to be possible in R2014b or later. It appears to me that the first button added to a uibuttongroup automatically has its Value set to 1.
Your options are:
- set() the Value of the first button to 0 after it is added to the uibuttongroup; or
- create a junk button first and add it to the uibuttongroup, and then after the other buttons are added, delete the junk button.
Sumera Yamin
on 23 Aug 2018
@ Walter Roberson Is it possible to set values of subsequent radio buttons to '3' and '4' ? So that when i select third or fourth radio buttons, only code relevant to that part is executed?
Walter Roberson
on 23 Aug 2018
The Value property of a button will be equal to the button's Min property if the button is not selected, and equal to the button's Max property if the button is selected.
So you could set the buttons to have 'Max', 1 for the first button, 'Max', 2 for the second, 'Max' 3 for the third, and so on. Then the Value property of the current button would tell you which of the buttons had been selected.
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)