How to use if elseif, if
11 views (last 30 days)
Show older comments
Underweight: BMI is less than 18.5 Normal weight: BMI is 18.5 to 24.9 Overweight: BMI is 25 to 29.9 Obese: BMI is 30 or more how to use if, elseif, if to Display BMI classification I did:
if(BMI<18.5)
BMI classification='underweight'
elseif(18.5<BMI<24.9)
BMI classification='Normal weight'
else(25<BMI<29.9)
BMI classification='Overweight'
end
0 Comments
Answers (1)
Youssef Khmou
on 11 Feb 2013
Hi try this :
BMI=input(' Enter BMI : ');
if(BMI<18.5)
classification='underweight'
elseif(18.5<BMI && BMI<24.9)
classification='Normal weight'
else(25<BMI && BMI<29.9)
classification='Overweight'
end
2 Comments
Image Analyst
on 11 Feb 2013
Edited: Image Analyst
on 11 Feb 2013
if BMI < 18.5
classification='underweight'
elseif 18.5 <= BMI && BMI < 24.9
classification='Normal weight'
elseif 24.9 <= BMI && BMI < 30
classification='Overweight'
else
classification='Obese'
end
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!