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 Solvers9580
Suggested Problems
-
Create a vector whose elements depend on the previous element
712 Solvers
-
Try 1.5.4: Celsius to Fahrenheit
831 Solvers
-
653 Solvers
-
327 Solvers
-
Find Air Temperature from Cricket Stridulation Rate
872 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!