Write a function that will rec
- Write a function that will receive two inputarguments that is the height in inches (in.) and the weight inpounds (lb) of a person and return two output arguments that is theheight in meters (m) and mass in kilograms (kg).
- Determine in SI units the height and mass of a 5 ft.15 in.person who weight 180 lb.
- Determine your own height and weight in SI units.
Note: 1 meter = 39.3701 inch,1 foot = 12 inches, 1 pound = 0.453592 kilogram
Solve this please usingMATLAP
Answer:
Answer:) The code for this function is as follows:
CODE:
%%% Function definitionfunction [ height_m, weight_kg ] = converter( height_in, weight_lb)% This function takes the height in inches and weight in poundsas% inputs, and outputs the height in meters and weight inkilograms feet = floor(height_in); % get the number of wholefeet inches = 100*(height_in – feet); % get the number ofinches height_m = (feet * 12 + inches) / (39.3701); % convertfeet to inches, % and then convert inches % to m weight_kg = 0.453592 * weight_lb; % use the conversionfrom pounds to kg disp(“Weight in kg : “) disp(weight_kg) disp(“Height in m : “) disp(height_m) returnend
The code looks as follows when typed out in MATLAB:
Suppose we give the input height = 5 ft 15 inches, weight = 180lb (given as an input which looks like (5.15, 180) ), we get :
>>converter(5.15, 180)Weight in kg :81.646559999999994Height in m : 1.904998971300556
OUTPUT:
Note: the final ‘ans’ is just the function returning the firstvariable’s value, and is the same as the height_m variable’svalue.
Suppose the user’s weight is 170 lb, and the user’s height is 6ft 10 inches. This would be :
>> converter(6.10, 170)Weight in kg :77.110640000000004Height in m : 2.082798875288606