BMI calculator, how do I Answer this
7 views (last 30 days)
Show older comments
Write a Matlab code that determines whether each student in a class has optimal weight, underweight, or overweight based a student’s body mass index (BMI). The BMI is often used to determine whether a person is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula:
BMI=weight×703/height2
where weight is measured in pounds and height is measured in inches.
A person’s weight is considered to be optimal if his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is considered to be underweight. If the BMI value is greater than 25, the person is considered to be overweight.
The code should be organised as follows:
- Write a getWgtHgt() function that asks the user to input the weight and the height vectors for the students and returns it. (Do NOT use loops) (2 marks)
- Write a getBMI() function that accepts the weight and the height vectors then returns a BMI vector which holds the BMI values for all students. (Do NOT use loops) (2 marks)
- Write a getResult() function that accepts the BMI vector then returns a string result vector indicating whether the student has optimal weight, underweight, or overweight. (Do NOT use loops) (4 marks)
- Write a main scriptto do the following: (4 marks)
- Call getWgtHgt() function to get the students’ weight and height vectors from the user.
- Call getBMI() to find the BMI values for each student.
- Call getResult() to determine his or her weight class based on the calculated BMI values for each student.
- Display the students result.
1 Comment
Sriram Tadavarty
on 26 Apr 2020
Can you show the code you tried so far? Where did you got struck in your trials?
Answers (1)
joseph vogulys
on 19 Aug 2020
Edited: joseph vogulys
on 19 Aug 2020
almost two days trying to figure it out
load patients.mat
whos
M=Weight*0.4536;
H=Height*0.0254;
bmi=Weight./(Height.^2);
BMI=M./(H.^2);
ax1 = subplot(3,1,1);
plot(ax1,BMI)
title(ax1,'BMI Body Mass Indices kg/m^2')
ax2 = subplot(3,1,2);
plot(M,'b--o')
title(ax2,'Weight KG')
ax3 = subplot(3,1,3);
plot(H,'b--o')
title(ax3,'Heigt M')
Regards from colombia
0 Comments
See Also
Categories
Find more on Resizing and Reshaping Matrices 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!