Given a matrix hw (height and weight) with two columns, calculate BMI using these formulas:
The first column is the height in inches. The second column is the weight in pounds.
function bmi = bmi_calculator(hw)
% Convert the height values from inches to meters
% Convert the weight values from lbs to kilograms
% Calculate the bmi for height and weight combination and return the output variable 'bmi'
bmi =new_weight./new_height.^2 ;
To test the code on MATLAB, the input hw was used as a table and it runs perfectly on MATLAB. But here it shows that the solution is wrong. Could anybody please explain?
The problem specifies that the input hw is a matrix with two columns (not a table). So, the error is saying that you cannot use dot indexing on a matrix.
Didn't know this is how simple BMI is.
I've got the right values but I've failed the assertion somehow?
The expected output is a column vector containing ALL the bmi values, whereas your code returns a single bmi value i.e. the last one. Hope that helps!
increase the tolerance value..i had to be very specific to match the result
Alphabetize by last name
Are all the three given point in the same line?
Matrix with different incremental runs
Basics: 'Find the eigenvalues of given matrix
Matlab Basics - y as a function of x
Crop an Image
Find the Best Hotels
Solve a System of Linear Equations
Calculate Inner Product
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office