A function can return a vector as a result Write a function
A function can return a vector as a result. Write a function that will receive one integer argument and will return a vector that increments by 1 from the value of the input argument to its value plus 5, using the colon operator. Verify your solution: input - 6 outputs 6 7 8 9 1011. Write a function to calculate the Body Mass Index (BMI) of a person. The function would receive weight in pounds and height in inches as input arguments and would return the BMI. BMI = 703 * weight/height^2 Verify your solution: weight -170 and height - 71 has BMI of 23.71
Solution
1.
x = input(\'Enter the number: \');
for i = 1:5
y(i) = x+i;
end
disp(\'Outputs\');
fprintf(\'%d \',y);
2.
weight = input(\'Enter wight in pound: \');
height = input(\'Enter height in inch: \');
BMI = 703*weight/height^2;
fprintf(\'BMI = %f \',BMI);
