image thumbnail
from Fourier Analysis of a Rectangular Pulse by Dimuthu Senanayaka
Fourier Analysis of the Rectangular pulse...

fft_of_rect_pulse.m
clear all
dt=.001;
t=[-25:dt:25];
x=(5/2)*(sign(t+10)-sign(t-10));
%subplot(2,2,1);
plot(t,x);
title('Rectangular pulse with width 10ms');
xlabel('time(ms)');
ylabel('Amplitude(V)');
axis([-25 25 0 6]);

pause


y=fftshift(fft(x));  % moving the zero-frequency component to the center of the array
N=length(y);         %to take the frquecny axis of the hoarmonics.
n=-(N-1)/2:(N-1)/2;  %divide the frequency compone
f=sqrt(y.*conj(y)); % to take the amplitude of each hoarmony.
  
title('Rectangular pulse amplitude');
xlabel('frequency component(harmoney)');
ylabel('Amplitude of the harmoney');

plot(n,f);  
axis([-50 50 0 150000]); 

pause

Contact us at files@mathworks.com