BMI calculator, how do I Answer this

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 commentaire

Sriram Tadavarty
Sriram Tadavarty le 26 Avr 2020
Can you show the code you tried so far? Where did you got struck in your trials?

Connectez-vous pour commenter.

Réponses (1)

joseph vogulys
joseph vogulys le 19 Août 2020
Modifié(e) : joseph vogulys le 19 Août 2020

0 votes

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

Catégories

Question posée :

le 26 Avr 2020

Modifié(e) :

le 19 Août 2020

Community Treasure Hunt

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

Start Hunting!

Translated by