フィルターのクリア

My function isn't returning an array for an answer with an input array

1 回表示 (過去 30 日間)
Kylenino Espinas
Kylenino Espinas 2020 年 10 月 8 日
コメント済み: Stephen23 2020 年 10 月 8 日
function [bodyMassIndex] = CalculateBMI(massKg, heightCm)
% Define a function CalculateBMI
% Input: massKg: Mass in kg
% heightCm: Height in cm
% Output: bodyMassIndex: Resulting BMI given mass and height
heightCm = heightCm / 100;
heightCm = nthroot(heightCm, 1/2);
bodyMassIndex= massKg / heightCm;
end
CalculateBMI([75, 90, 118], [178, 180, 200])

採用された回答

Walter Roberson
Walter Roberson 2020 年 10 月 8 日
bodyMassIndex= massKg ./ heightCm;
The operator you used, /, is about the same as if you had written
bodyMassIndex= massKg * pinv(heightCm);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSystems of Nonlinear Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by