Homework 6-MATLAB Arrays This homework is an individual assignment. Upload all r
ID: 2248841 • Letter: H
Question
Homework 6-MATLAB Arrays This homework is an individual assignment. Upload all required files to eCampus by the due date. Remember to sign your work The body Surface area (BSA) of a person in m2 can be calculated when the mass (in kg) and height (in cm) is known using the Du Bois formula: BSA = 0.007 184 masso 425 height0.75 For example, the BSA of a person with a height of 187 cm and a mass of 75 kg would be calculated as 2.2759 m2 Write a function called bodySurfArea that accepts a 2-column array as input. The first column contains values of mass in kg and the second column contains corresponding heights in meters. Your function must use the Du Bois formula to compute the coresponding value of BSA for each mass-height pair of values. It should return a 3-column array with the mass, height, and BSA values in the respective columns Include help comments and other descriptive comments in both functions, and ensure that they do not accept nonsensical input.Explanation / Answer
Ans )=================MATLAB CODE===============
function [ Mass_Height_BSA ] = bodySurfArea( Mass_Height )
%BODYSURFAREA Summary of this function goes here
% Detailed explanation goes here
[R ,C]=size(Mass_Height); %returns no of Rows and Columns of the given array
if C~=2 %check whether no colums is 2 or not
error('Error. Input must be a two column array') %display error message
end
for i=1:R %traverse through all rows and find BSA for all
mass=Mass_Height(i,1); %mass is in first column
height=Mass_Height(i,2)*100;%Height is in second column as we need in 'cm' we multiplied by 100
BSA(i)=0.007184*mass^0.425*height^0.75;%equation to calculate BSA
end
Mass_Height_BSA=[Mass_Height BSA'];%output all 3 columns mass height BSA
end
==============================
Output in command window
=
>> M=[75 1.87;80 2;90 3];
>> bodySurfArea(M)
ans =
75.0000 1.8700 2.2759
80.0000 2.0000 2.4601
90.0000 3.0000 3.5056
>>
=====================
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.