Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for M=[5 10 20 40 80 160]
- t=0:0.001:2*pi;
- e=exp(1);
- N=length(t);
- x=zeros(1,N);
- x(1:N/2)=1;
- xa=zeros(1,N);
- for k=-M:M
- if (k==0)
- a=0.5;
- elseif (floor(k/2)*2==k)
- a=0;
- else
- a=-i/(pi*k);
- end
- xa=xa+a*e.^(i*t*k);
- end;
- xa=real(xa);
- max(xa)
- figure
- plot(t,x,t,xa)
- axis([0,2*pi,-0.2,1.2]);
- title(strcat('Partial sum of Fourier series M = '...
- ,int2str(M)),'FontName', 'Arial CE');
- xlabel('t');ylabel('x(t), x_a(t)');
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement