How can I define conditional units in App Designer?

46 visualizaciones (últimos 30 días)
Matt Brown
Matt Brown el 13 de Dic. de 2021
Respondida: Reshma Nerella el 17 de Dic. de 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!

Respuesta aceptada

Reshma Nerella
Reshma Nerella el 17 de Dic. de 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
Refer to the documentation page to know more about button group callbacks.
Hope this helps!

Más respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by