Nice
function bmi = bmi_calculator(hw)
h_inch = hw(:,1);
h_m = h_inch .* 2.54/100;
w_pounds = hw(:,2);
w_kg = w_pounds .* 0.453592;
BMI = w_kg / (h_m .* h_m);
bmi= BMI(:,end);
end
IM GETTING ASSERTION ERROR....EVEN THOUGH IT GIVES ME EXACT OUTPUT ON MY MACHINE. ANYONE HAVING IDEA ABOUT THIS ?
was getting an assertion error but finally got it after 15 minutes of brainstorming
function bmi = bmi_calculator(hw)
% Convert the height values from inches to meters
height=hw(:,1)./(2.54*10^-2)
% Convert the weight values from lbs to kilograms
weight=hw(:,2)./2.2
% Calculate the bmi for height and weight combination and return the output variable 'bmi'
bmi = weight./(height.^2);
end
can anyone help me to find the aassertion error?
I solved the problem but the weird thing is that I had to multiply the bmi result with 10000 ro get the right results. Somehow the results without the multiplication were not the exact results. Have anyone faced the same things?
"The condition input argument must be convertible to a scalar logical."
how this error is rectified?
function bmi = bmi_calculator(hw)
hwm=hw(:,1)*2.54/100;
hwk=hw(:,2)/2.2;
bmi = hwk./(hwm.*hwm);
end
Dividing height in inches by dividing by 39.37 fails. However, 39.3701 passes first test but fails the second. I had to find a closer value to satisfy second test, 39.37008. You should improve the test parameters.
bmi_correct and bmi_calculator are same. even then I am getting assertion error
this is a good problem . i learn a lot from this
w=hw(:,2)
w=w./2.2
h=hw(:,1)
h=1./[[h.*.0254].^2]
bmi=w.*h
solution for help
What is wrong i this code, The final answers are also matching but it is showing as a fail, I am not getting it.
Leading solution is not correct. The code has comment to convert the height and weight seperately followed by the bmi computation. bmi should not be calculated in one line of code as in leading solution by crunching all the factors.
a very narrow range of assertions. The solution is correct, but can not proceed due to narrow limits of the assertions.
function bmi = bmi_calculator(hw)
% Convert the height values from inches to meters
new_height= hw.height*2.54/100;
% Convert the weight values from lbs to kilograms
new_weight=hw.weight/2.2;
% Calculate the bmi for height and weight combination and return the output variable 'bmi'
bmi =new_weight./new_height.^2 ;
end
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
Nice!
function bmi = bmi_calculator(hw)
% Convert the height values from inches to meters
height=hw(:,1)*(2.54)/100
% Convert the weight values from lbs to kilograms
weight=hw(:,2)*(1/2.2)
% Calculate the bmi for height and weight combination and return the output variable 'bmi'
bmi = weight./(height.*height)
Hi All,
I'm getting correct result in my computer but in this platform it is giving me assertion error.
% Convert the height values from inches to meters
height= 2.54*0.01*hw(:,1)
% Convert the weight values from lbs to kilograms
weight= (1/2.2)*hw(:,2)
% Calculate the bmi for height and weight combination and return the output variable 'bmi'
bmi=(weight./(height.^2))'
bmi = hw;
Kindly suggest me the way to fix this issue.
3322 Solvers
392 Solvers
360 Solvers
303 Solvers
Height of a right-angled triangle
382 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!