Write a userdefined MATLAB function with two input and two o
Write a user-defined MATLAB function, with two input and two output arguments that determines the height in centimeters (cm) and mass in kilograms (kg)of a person from his height in inches (in.) and weight in pounds (lb).
(a) Determine in SI units the height and mass of a 5 ft.15 in. person who weight 180lb.
(b) Determine your own height and weight in SI units.
Solution
MATLAB code
clear all
close all
clc
H=input(\'Enter your hight in the form of [ft in] = \');
w=input(\'Enter your weight in lb = \');
sI_Height = (H(1)*30.48)+(H(2)*2.54)
sI_weight = w*0.453592
sample outputs are
(a)
Enter your hight in the form of [ft in] = [5 5]
Enter your weight in lb = 180
sI_Height =
165.1000
sI_weight =
81.6466
>>
(b)
Enter your hight in the form of [ft in] = [5 9]
Enter your weight in lb = 176
sI_Height =
175.2600
sI_weight =
79.8322
>>
