This is not the purpose of SWITCH/CASE. Please read the documentationm again:
SWITCH evaluates its argument, ibn your case the variable body. Then it compares it with the expressions after the case statements. If body is e.g. 18, you get:
switch 18
case FALSE
...
case TRUE
...
But 18 is neither TRUE nor FALSE.
You want an IF command instead of SWITCH.
if (body < 17)
s = 'Underweight';
elseif (body >=17) && (body < 23)
s = 'Normal';
elseif (body >= 23) && (body < 27)
s = 'Overweight';
else
s = 'Obese';
end
You can simplify this: After body<17 has been excluded already, there is no need to check for body >= 17 again. So htis is sufficient:
if (body < 17)
s = 'Underweight';
elseif (body < 23)
s = 'Normal';
elseif (body < 27)
s = 'Overweight';
else
s = 'Obese';
end