numerical analsis using MatlabWhile loops Write an Mfile tha

numerical analsis

(using Matlab)While loops: Write an M-file that uses a while loop to find the values of f(n) = 2n/ (sqroot(n2 + 3n) for n = 1, 2, 5, 10, 100, 1000, 20000. Your M-file should output a table of values with two columns–one for n and one for f(n). Make sure that you have comments at the beginning of the M-file that tell the user what it does.

Solution

clc;
clear all;
A=zeros(2,7);%declare 2d array
%put value in first row
A(1,1)=1;
A(1,2)=2;
A(1,3)=5;
A(1,4)=10;
A(1,5)=100;
A(1,6)=1000;
A(1,7)=20000;
[m n]=size(A);

while i<n+1
    A(2,i)=(2*A(1,i))/(sqrt(A(1,i)*A(1,i)+3*A(1,i)));% evaluate f(n)
    i=i+1;
end
A

numerical analsis (using Matlab)While loops: Write an M-file that uses a while loop to find the values of f(n) = 2n/ (sqroot(n2 + 3n) for n = 1, 2, 5, 10, 100,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site