Question: 2. Write a function bmiCalc() that takes two inputs; a filename with personal data (char array), and the name of a person of interest (a

2. Write a function bmiCalc() that takes two inputs; a filename with personal data (char array), and the name of a person of interest (a string). The function will return the BMI of the person of interest. The data file is provided on Moodle. First read the data from the file using readcell() Use a for loop and a built in function (check reference sheet) to compare the name of the person of interest to the names provided in the data file and extract the mass and height of ONLY the person of interest. The height is the second column, the mass is the third. Be careful when using {} or () to index. There is a difference. Calculate BMI = mass (kg) / height(in)? Return the calculated BMI The function header and an example run are provided below. function [bmi] = bmicalc(filename, personName) Using the data provided in filename, returns the BMI of the user whose string name is the string personName Inputs: filename - character array of the personal data file personName - name of the person whose BMI is to be calculated Returns: bmi - bmi found by mass/ height^2 Command Window >> BMI_Jack = bmiCalc('BMI_Data.xlsx', "Jack") BMI_Jack = 20.518 fx >>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
