MATLAB Answers

How to obtain radio button index in APP Designer

8 views (last 30 days)
Brian on 29 Aug 2018
Commented: Greg on 30 Aug 2018
I'm new to APP Designer. I've made a simple APP that has radio buttons which correspond to the names of the columns in an ascii file that I have read in. I want to plot different columns of the file (e.g. Time vs Pressure, Time vs Temperature, etc.) when I select a button.
so, when I click on a button, I want to plot columns 1 vs buttonnumber e.g
in the UIAxes. How do I get the button number from the buttonclick callback? I don't see it in the properties of the buttongroup.


Sign in to comment.

Accepted Answer

Greg on 30 Aug 2018
Edited: Greg on 30 Aug 2018
There are a few ways to do it, each with a different level of impact to your code. The way that requires no changes except a new line of code to define buttonnumber is:
buttonnumber = ismember(app.grpRadioButtons.Buttons,app.grpRadioButtons.SelectedObject);
Obviously, you'll have to put in your own appropriate tag for the radio button group. Also, I personally wouldn't use the variable name buttonnumber since this is strictly a logical output (which works exactly as-is to index into data). If you truly (superfluously) want the numeric value, throw a find on it.


Show 1 older comment
Greg on 30 Aug 2018
My approach for listbox (and others) is to stick the numeric index into the ItemsData property. Querying the Value property then defaults to the content of ItemsData, but you can easily use that to index into Items to get the actual text.
I've been asking for an Index property of these types of components for a little while now. Hopefully soon.

Sign in to comment.

More Answers (0)