image thumbnail

Fourier Analysis of a Rectangular Pulse

by

 

14 Oct 2009 (Updated )

Fourier Analysis of the Rectangular pulse...

run.m
clear all
hw=10;

dt=.001;
t=[-60:dt:60];

%% ractangular pulse.

x=(5/2)*(sign(t+hw)-sign(t-hw));
plot(t,x);
title(['Rectangular pulse width-',num2str(2.*hw),'ms']);
xlabel('time(ms)');
ylabel('Amplitude(V)');
rge=40;
axis([-rge rge 0 6]);
pause

%% rectangular pulse frequency content by fourier analysis.

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.  
plot(n,f);  

%**************************************************************************
axis([-120 120 0 120000]);  %for part 5
%**************************************************************************


title(['Rectangular Pulse(width-',num2str(hw),'ms',')  frequency distribution']);
xlabel('frequency(Hz) ');
ylabel('Amplitude');
pause


%%%%reconstructing the rectangular pulse using the fourier components of the signal.
Y=ifft(y);  %taking the inverse fourier transformation from given transform arry.
plot (t,abs(Y));
axis([-rge rge 0 6]);
xlabel('time(ms)');
ylabel('amplitude(V)');
title('Regenarated squar signal from fourier coefficients');

%filter making for fikter the signal frequency content
pause
fil=(1/2)*(sign(n+100)-sign(n-100));
plot(n,fil);
axis([-120 120 0 1.5]);

title(['Filter']);
xlabel('frequency(Hz)');
ylabel('Amplitude(V)');

pause
f0=fil.*f;  %filtering the amplitudes of the fourier series 
plot(n,f0);
title(['Filtered Rectangular Pulse(width-',num2str(hw),'ms',')  frequency distribution']);
xlabel('frequency(Hz)');
ylabel('Amplitude');
%**************************************************************************
%axis([-100 100 0 320000]);  %for part 1
axis([-120 120 0 120000]);  %for part 5
%**************************************************************************



pause;


%regenaration of signal using filtered frequency content.
f2=fil.*y; %f2 is the filtered output of original frequency content
Y1=ifft(f2);  %reverse fourier series.
plot (t,abs(Y1));
axis([-rge rge 0 6]);
xlabel('time(ms)');
ylabel('amplitude(V)');
title('Regenarated squar signal from filtered (100Hz) fourier coefficients');











Contact us