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 commentsGroup

Project Euler II
- 12 Problems
- 51 Finishers
- Find the longest sequence of 1's in a binary sequence.
- Convert given decimal number to binary number.
- Find out sum and carry of Binary adder
- Binary numbers
- Given an unsigned integer x, find the largest y by rearranging the bits in x
- Bit Reversal
- Relative ratio of "1" in binary number
- Binary code (array)
- Converting binary to decimals
- There are 10 types of people in the world
Problem Recent Solvers9580
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!