Mathlab Help Fibonacci numbers are the numbers in a sequence
Mathlab Help!
Fibonacci numbers are the numbers in a sequence in which the first two numbers are 0 and 1, and the value of each subsequent element is the sum of the previous two elements, as show below: 0, 1, 1, 2, 3, 5, 8, 13, …
Write a Matlab program in a script file that determines and displays the first 20 Fibonacci numbers.
HINT: The easy way is to use a for-end loop like you did in the weeks past.
This is what I have so far
T = zeros(50, 1);
 Y = zeros(50, 1);
 dY = zeros(50, 1);
for i=1:1:50
     T(i) = i;
     Y(i) = 1-exp(-1.0*i/10);
     if i>1
         dY(i-1) = Y(i) - Y(i-1);
     end
 end
 Table = table(T, Y, dY);
 disp(Table);
 plot(T, Y);
 plot(T, dY);
Solution
%Create a matlab file called Fibonacci.m
%set number of fibonnaci numbers,N=20
N=20;
 %create a vector of size,N=20
f=zeros(1,N);
 f(1)=0;
 f(2)=1;
 i=3;
%create a fibonacci series for N elements
%using for loop
for i=3:N
 f(i)=f(i-2)+f(i-1);
     i=i+1;
 end
 
 fprintf(\'First %d numbers of Fibonacci series is\ \',N);
 %print series
fprintf(\'%g \',f);
fprintf(\'\ \');
---------------------------------------------------------------------------------------
Run the script from the console.
First 20 numbers of Fibonacci series is
 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181


