how to use switches on app designer

37 views (last 30 days)
Ashwin Palanisamy
Ashwin Palanisamy on 6 May 2020
Answered: Mehmed Saad on 6 May 2020
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.

Answers (1)

Mehmed Saad
Mehmed Saad on 6 May 2020
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

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!