how to use switches on app designer

39 次查看(过去 30 天)
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 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