T0 = 1; t = 0:0.02:T0; w0 = 2*pi/T0; plot(t, cos(w0*t)) hold on plot(t, sin(3*w0*t),'r') hold off % Finding the expansion for f(t) = t k = 1; dt = 0.01; t = 0:dt:T0; ak = 2*dt*sum( cos(w0*k*t).* t); bk = 2*dt*sum( sin(w0*k*t).* t); approx1 = 1/2 + ak * cos(w0*k*t) + bk * sin(w0*k*t); plot(t,t); hold on plot(t, approx1,'.');