How can I define conditional units in App Designer?
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Matt Brown
il 13 Dic 2021
Risposto: Reshma Nerella
il 17 Dic 2021
This is my first attempt at App Designer, so pardon my ignorance. I want to provide the user with the option to change between unit systems using a radio button. The execution of that is simple enough, but I am at a loss how to display and change units to accompany the input fields. For example, if the user selects SI units, then the units of the Altitude input should be m, if they choose BG then it should be ft. I started off trying to create simple labels next to the inputs thinking I could make those conditional (if/then), but it's not working out for me. I would really appreciate a shove in the right direction.
Also, it seems from other questions I have reviewed that using super/subscripts in labels is not supported, for example area in m^2. Can anyone confirm if that has changed in R2021 or if that remains unsupported.
HELP!
0 Commenti
Risposta accettata
Reshma Nerella
il 17 Dic 2021
Hi
Add selectionChanged callback for the button group. Get the button text everytime the value is changed and accordingly change the labels
For instance,
function ButtonGroupSelectionChanged(app, event)
selectedButton = app.ButtonGroup.SelectedObject.Text;
if strcmp(selectedButton, "BG")
% modify labels text according to BG units
app.m2Label.Text = 'm^2';
app.kgsLabel.Text = 'kg/s';
else
% modify labels text according to SI units
app.m2Label.Text = 'x';
app.kgsLabel.Text = 'y';
end
end
Hope this helps!
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!