This is a matlab question please include code and answers. thank you We already
ID: 3747156 • Letter: T
Question
This is a matlab question please include code and answers. thank you
We already have a function file to compute body mass index (BMI). Now write a .m function file that takes height, weight, gender (0 for female, 1 for male), and age and outputs the body fat percentage (BFP) (another silly metric). BFP = 1.2BMI + 0.23(age) 10.8(gender) 5.4 Write your function so that it calls the BMI function you wrote earlier.
Code for BMI function
function b=BMI_Index(weight, height)
w=weight
h=height
H=w/h^2
b=703*H
(a) Abraham Lincoln was a 6’4”, 180 lb, 52 year-old president. What was his BFP?
(b) NFL MVP Peyton Manning was a 6’5”, 230 lb, 40 year-old man when he won the Superbowl. What was his BFP?
Explanation / Answer
--------------------BMI_Index.m-------------------
function b = BMI_Index(weight, height)
w=weight;
h=height;
H=w/h^2;
b=703*H
end
---------------------------BFP_Index.m-------------------------
function [val] = BFP_Index(height, weight, gender , age)
val = 1.2 * BMI_Index( weight, height ) + 0.23 * age - 10.8 * gender - 5.4;
end
----------------------main.m----------------------
% 6'4'' is equal to 1.9304 meters
% 180 lb = 81.6466 kg
fprintf('BFp of Abraham Lincoln : %f ' , BFP_Index( 1.9304 , 81.6466 , 52 , 1 ));
% 6'5'' is equal to 1.9558 meters
% 230 lb = 104.326 kg
fprintf('BFp of NFL MVP Peyton Manning : %f ' , BFP_Index( 1.9558 , 104.326 , 40 , 1 ));
Sample Output
BFp of Abraham Lincoln : -540.477933
BFp of NFL MVP Peyton Manning : -404.441589
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.