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