how to use switches on app designer

39 ビュー (過去 30 日間)
Ashwin Palanisamy
Ashwin Palanisamy 2020 年 5 月 6 日
回答済み: Mehmed Saad 2020 年 5 月 6 日
I am using Matlab app designer to create a gui for my unit converter. To do this i have decided to use a switch that will allow the user to flip between metric to imperial and imperial to metric. However, when i change the swtich to imperial to metric, the items in the drop box do not change. I have attatched my code, i hope someone can guide me in the right direction. I have tried using if statements to make this happen however it fails to register the changed value of the switch.
Thank you.

回答 (1 件)

Mehmed Saad
Mehmed Saad 2020 年 5 月 6 日
In line 40 of your code
if strcmpi(conversionvalue, 'temperature') && strcmpi(switchvalue, 'imperial to metric')
the string which is coming from switchvalue is
'imperial to metric '
i.e. 1 space at the end
It is better to give switches values in items data
so now instead of passing the complete string it will pass 0 or 1
if strcmpi(conversionvalue, 'temperature') && (switchvalue==0)
You can also apply similar strategy on conversion type

カテゴリ

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