フィルターのクリア

Help with BMI Calculation

1 回表示 (過去 30 日間)
Swati Sarangi
Swati Sarangi 2020 年 11 月 5 日
コメント済み: KSSV 2020 年 11 月 6 日
Hi All,
Here's the code that I've written for BMI calculation , but my code is not being accepted in Cody. I checked that code with test cases in my MATLAB software and it is satisfying the condition.Can someone tell me where the error is.
% Cody
% BMI calculation ; weight(kg)/height(m)^2
% 1kg=2.2 pound, 1 inch=2.54 cm
hw = [66 155;60 140;72 166;58 160;75 215];
hw1=[10 80];
% 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;
Thanks in advance!
Swati
  4 件のコメント
Swati Sarangi
Swati Sarangi 2020 年 11 月 6 日
No, it's not a function. I tried this code with MATLAB installed in my laptop.
KSSV
KSSV 2020 年 11 月 6 日
bmi=(weight./(height.^2))'
bmi = hw;
You calculated the bmi values; and then you replaced them with existitng variable hw....

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeIntroduction to Installation and Licensing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by