Matlab Experiment

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

AIM : To verify the following properties of the discrete Fourier

transform
1. Convolution Property
2. Time Shifting Property
3. Frequency Shifting Property

%To analyze the convolution property


close all;
clear all;
j=5;l=4;n=20;k=2;m=3;
%defining two rectangular pulses
x1=[zeros(1,j) ones(1,n-j-k) zeros(1,k)];
x2=[zeros(1,l) ones(1,n-l-m) zeros(1,m)];
%computing the fourier transforms p point fft, p=300
dft1=fft(x1,300);
dft2=fft(x2,300);
%sample by sample product of two fft's
dfty=dft1.*dft2;
y=ifft(dfty);
%convolution of original signals
y1=conv(x1,x2);
subplot(2,1,1);stem(y);
AXIS([0 50 0 20]);
xlabel('samples');ylabel('idft of dft1.*dft2');
title('Product of DFTs of two Square Pulses');
subplot(2,1,2);stem(y1);
AXIS([0 50 0 20]);
xlabel('sample');ylabel('convolution 0f x1 and x2');

OUTPUT-:

2.
Code-:

%To verify the time-shifting property


close all;
clear all;
%defining the rectangular pulse
x1=[zeros(1,10) ones(1,10) zeros(1,10)];
G=7;P=30;
%P=length of rectangular pulse
dft1=fft(x1,30);
%M point fft
for n=1:1:30
DFTY2(n)=dft1(n).*exp(G*1i*(2*pi/P)*n);
y1=ifft(DFTY2);
end
subplot(2,1,1);stem(x1);
xlabel('sample');ylabel('x1');
title(' Original rectangular pulse')
subplot(2,1,2);stem(abs(y1));
xlabel('samples');ylabel('idft y1');
title('The Resulting Shifted Signal by G=7 points');

OUTPUT-:

Q3.
Code-:

%To verify the frequency-shifting property


close all;
clear all;
%defining the rectangular pulse
x1=[zeros(1,10) ones(1,10) zeros(1,10)];
H=7;P=30;
%P=N=30=length of rectangular pulse
dftx1=fftshift(fft(x1,30));
%M point fft
for n=1:1:30
x3(n)=x1(n).*exp(H*1i*(2*pi/P)*n);
dftx3=fftshift(fft(x3,30)); %M point fft
end
m=2*(pi/30)*[0:1:29];
subplot(3,1,1);stem(x1);
xlabel('samples');ylabel('x1');
title('Original rectangular pulse');
subplot(3,1,2);stem(m,abs(dftx1));
set(gca,'XTick',0:pi/2:2*pi);

set(gca,'XTickLabel',{'0','0.5*pi','pi','1.5*pi','2*pi'});
xlabel('samples');ylabel('DFT of X1[n]');
title('Fourier transform of original pulse X1[n]');
subplot(3,1,3);stem(m,abs(dftx3));
set(gca,'XTick',0:pi/2:2*pi);
set(gca,'XTickLabel',{'0','0.5*pi','pi','1.5*pi','2*pi'});
xlabel('samples');ylabel('dft of X3[n]');
title('The DFT (of x3[n])is shifted spectrum of X1[n] by 2*pi*H/P=1.46=0.46*pi,
P=N=30, H=7');
OUTPUT-:

You might also like