Cody

Problem 44945. Calculate BMI

Solution 2987893

Submitted on 24 Sep 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
hw = [66 155;60 140;72 166;58 160;75 215]; bmi_correct = [25.0700;27.3990;22.5607;33.5100;26.9293]; assert(all(abs(bmi_calculator(hw) - bmi_correct) < 1e-4))

h = 1.6764 1.5240 1.8288 1.4732 1.9050 w = 70.4545 63.6364 75.4545 72.7273 97.7273

Error using ^ (line 51) Incorrect dimensions for raising a matrix to a power. Check that the matrix is square and the power is a scalar. To perform elementwise matrix powers, use '.^'. Error in bmi_calculator (line 11) bmi=w./(h^2) Error in Test1 (line 3) assert(all(abs(bmi_calculator(hw) - bmi_correct) < 1e-4))

2   Pass
hw = [10 80]; bmi_correct = 563.6375; assert(all(abs(bmi_calculator(hw) - bmi_correct) < 1e-4))

h = 0.2540 w = 36.3636 bmi = 563.6375

Suggested Problems

More from this Author13

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!