Pages

Monday, December 13, 2010

MATLAB PROGRAM TO DISPLAY THE PROPERTIES OF DISCRETE FOURIER TRANSFORM (DFT) - LINEARITY PROPERTY

%DFT linearity property
close all;
clear all;
N=input('Howmany point DFT  do you want?');
x1=input('Enter the first sequence=');
x2=input('Enter the second sequence=');
a=input('Enter the first constant a=');
b=input('Enter the second constant b=');
n1=length(x1);
n2=length(x2);
c=zeros(N);
x1=[x1 zeros(1,N-n1)];%make both x1 and x2 
x2=[x2 zeros(1,N-n2)];%of same dimension
x3=a*x1
x4=b*x2
x5=x3+x4 %a*x1+b*x2
for k=1:N
     for n=1:N
         w=exp((-2*pi*i*(k-1)*(n-1))/N);
         %prev.step=>evaluating w-matrix
         x(n)=w;
     end
     c(k,:)=x;  %Every row of w-matrix is inserted &
end             %finally c becomes the w matrix
                %for n-point DFT

 r1=c*x1';   %x1(k)   
 r2=c*x2';   %x2(k)
 R3=a*r1+b*r2  %a*x1(k)+b*x2(k)
 R4=c*x5'      %DFT of a*x1(n)+b*x2(n)
 %plotting magnitude and angle
subplot(211)
stem(abs(R4));
title('DFT of {a*x1(n)+b*x2(n)}');
subplot(212)
stem(angle(R3));
title('DFT of {a*x1(k)+b*x2(k)}');

 
OUTPUT WAVEFORM

 

No comments:

Post a Comment