Rectangular function generator y=[]; for x=-T:T/1000:T z=(-T/2<x&x<T/2); y=[y z]; end x=-T:T/1000:T; plot(x,y) Triangular function generator y=[]; for x=-T:T/1000:T z=(-T/2<x&x<0)*(2/T*x+1)+(0<x&x<T/ 2)*(-2/T*x+1)+(x==0); y=[y z]; end x=-T:T/1000:T; plot(x,y)
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Rectangular function generatory=[];for x=-T:T/1000:Tz=(-T/2<x&x<T/2);y=[y z];endx=-T:T/1000:T;plot(x,y)
Plotting reconstructed signal for a given number of Fourier coefficients
function z=time(x,T);y=0;g=[];n=(length(x)-1)/2;for t=-T:T/1000:T; y=0; for k=1:(2*n+1); m=x(k)*exp(j*(k-n-1)*2*pi/T*t); y=y+m;endg=[g y];endt=-T:T/1000:T;plot(t,g)