Problem 44945. Calculate BMI
- 1 kilogram = 2.2 pounds
- 1 inch = 2.54 centimeters
- BMI = weight(kg) / [height(m)]^2
Solution Stats
Problem Comments
-
18 Comments
function bmi = bmi_calculator(hw)
% Convert the height values from inches to meters
h=reshape(hw(:,1),1,[]);
h=0.0254*h;
% Convert the weight values from lbs to kilograms
w=reshape(hw(:,2),1,[]);
w=(1/2.2)*w;
% Calculate the bmi for height and weight combination and return the output variable 'bmi'
bmi=w./(h.^2);
end
what is wrong with this, please help. It runs fine on RUN button but does not pass the test
@Prathamesh Using your code, bmi is returned as a row vector, but the test suite expects a column vector.
In this excercise the big deal is to recognice that the solution must be in the same format as the entry data. That in this case is a Column Vector.
Solution Comments
Show commentsProblem Recent Solvers9587
Suggested Problems
-
Find relatively common elements in matrix rows
2087 Solvers
-
Find the maximum number of decimal places in a set of numbers
2991 Solvers
-
Who is the smartest MATLAB programmer?
763 Solvers
-
Find last zero for each column
591 Solvers
-
Calculate the average value of the elements in the array
1328 Solvers
More from this Author13
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!