Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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])

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Systems of Nonlinear Equations dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by