How can I define conditional units in App Designer?
11 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Reshma Nerella
2021-12-17
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!