How to obtain radio button index in APP Designer

조회 수: 2 (최근 30일)
Brian
Brian 2018년 8월 29일
댓글: Greg 2018년 8월 30일
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
plot(app.UIAxes,app.data(:,1),app.data(:,buttonnumber))
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.

채택된 답변

Greg
Greg 2018년 8월 30일
편집: Greg 2018년 8월 30일
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.
  댓글 수: 4
Brian
Brian 2018년 8월 30일
Perfect, thanks!
Greg
Greg 2018년 8월 30일
Happy to help!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by