How can i use a switch and a drop down menu? matlab appdesigner

4 次查看(过去 30 天)
For my unit converter im trying to have it so that i have a switch that can select metric to imperial or imperial to metric, and have a drop down menu that will allow th euser to slect what they wish to convert eg, temperature, distance, mass. However, I dont really know how to code a && in the callback function that will allow me to change the items in the third drop down menu. for example, to make it so that if the user changes the switch to 'metric to imperial' and selects length. how do I make it so the second drop down menu will take into considration both of these user inputs and display 'cm to inch' so on and so forth?
I will provide a screenshot of my code and please try not to facepalm. I am new to matlab programming.

采纳的回答

Geoff Hayes
Geoff Hayes 2020-5-4
Ashwin - one problem with your conversiontypeDropDownValueChanged callback, you are using the same variable name for to represent two different values
value = app.converstiontypeDropDown.Value;
value = app.Switch.Value;
if strcmpi(value,'temperature') && strcmpi(value, 'metric to imperial')
% etc.
end
Try renaming the variables to distinguish one from the other and to give you an idea as to what each represents.
conversionValue = app.converstiontypeDropDown.Value;
switchValue = app.Switch.Value;
if strcmpi(conversionValue,'temperature') && strcmpi(switchValue, 'metric to imperial')
% etc.
end
Also, please include attach your code rather than a screen shot of it.
  2 个评论
Ashwin Palanisamy
Ahhh I see.
Thank you so much mate, I appreciate your help. would you still like me to attatch my code file?
Geoff Hayes
Geoff Hayes 2020-5-4
No need to attach your code...but next time, it would be preferrable to attach it rather than a screen shot.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile 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!

Translated by