My function isn't returning an array for an answer with an input array
3 views (last 30 days)
Show older comments
Kylenino Espinas
on 8 Oct 2020
Commented: Stephen23
on 8 Oct 2020
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])
Accepted Answer
Walter Roberson
on 8 Oct 2020
bodyMassIndex= massKg ./ heightCm;
The operator you used, /, is about the same as if you had written
bodyMassIndex= massKg * pinv(heightCm);
0 Comments
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!