Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clc
- clear all
- close all
- t=0:0.01:10;
- x=[ones(1,201),zeros(1,99),ones(1,201),zeros(1,99),ones(1,201),zeros(1,99),ones(1,101)];
- T=3;
- w=2*pi/T;
- dtau=0.1;
- for k=-10:10
- sum = 0;
- i=1;
- for tau=0:dtau:T
- exp_part = exp(-j*w*k*tau)*dtau;
- sum = sum + exp_part.*x(i);
- i=i+1;
- end
- a(k+11) = sum;
- end
- for i=1:21
- mag(i) = abs(a(i));
- phase(i) = angle(a(i));
- end
- k=-10:10;
- subplot(2,2,[1:2]);
- plot(t,x);
- title('Input Signal (A Pulse Train)');
- xlabel('Time');
- ylabel('Amlitudeof the signal');
- subplot(2,2,3);
- stem(k,mag);
- title('Magnitude Spectra');
- xlabel('k \rightarrow');
- ylabel('Magnitude');
- subplot(2,2,4);
- stem(k,phase,'Linewidth',1.2);
- title('Phase Spectra');
- xlabel('k \rightarrow');
- ylabel('Phase');
Add Comment
Please, Sign In to add comment