Please Explain each MATLAB code Write a function that calcul

Please Explain each MATLAB code

Write a function that calculates your Body-mass-index (BMI) using the following formula: BMI = mass(kg)/height(m)^2 After writing the function, calculate your body-mass-index by using your function in the command window. Write a function that calculates the factorial of the input number. Write a function that shows the \"n\" Fibonacci numbers using the following formula: f(0) = 1 f(1) = 1 f(n) = f(n - 1) + f(n - 2) Audio Chopping (Hard):

Solution

1.

function bm= bmi()
weight = input(\'Type your weight (kg): \');
height = input(\'Type your height (m): \');
bm = weight / height^2;
  
fprintf(\'Your Body Mass Index is %f\ \", bm);

end

2.

function f= facat()
n= input(\'type your number:\');
for i=1:n
   f=f*i;
end
fprintf(\"Factorial of given no %d\ \",f);
end

3.

function f = fib(n)
f=zeros(n,1);
f(1)=1;
f(2)=2;
for k=3:n
   f(k)=f(k-1)+f(k-2);
end
end

4.

load handel.mat
function g=sample()
filename=\'audio.wav\';
[y,fs]=audioread(filename);
g=zeros(3,1);
for i=1:3
   g(i)=y(i*(1/fs));
end
end

Please Explain each MATLAB code Write a function that calculates your Body-mass-index (BMI) using the following formula: BMI = mass(kg)/height(m)^2 After writin

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site