For this periodic function Write a MATLAB code in a loop exp
For this periodic function, Write a MATLAB code in a loop expand the Fourier series to n=5000 and plot the function
Where the Fourier series is
Please follow the eqations above to provide the code.
f(t) = , 1 1 0Solution
Matlab Code
ao = 0;
 for i =1:5000
     a(i) = 0;
     b(i) = (1 + cos(2*i*pi) - 2*cos(i*pi))/(i*pi);
 end
 t = 0:0.01:2;
 g=@(t)0;
 for i=1:5000
     f = @(t)b(i)*sin(i*pi*t);
     g = @(t)(g(t)+f(t));
 end
 plot(t,g(t))

