A function can return a vector as a result. Write a function that will receive o
ID: 2325035 • Letter: A
Question
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.71Explanation / Answer
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);
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.