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

3 ビュー (過去 30 日間)
Ashwin Palanisamy
Ashwin Palanisamy 2020 年 5 月 4 日
コメント済み: Geoff Hayes 2020 年 5 月 4 日
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
Ashwin Palanisamy 2020 年 5 月 4 日
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 Center および File ExchangeDevelop 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