Pages

Tuesday, December 14, 2010

MATLAB PROGRAM TO IMPLEMENT DISCRETE FOURIER TRANSFORM

%DFT
close all;
clear all;
N=input('Howmany point DFT  do you want?');
x2=input('Enter the sequence=');
n2=length(x2);
c= zeros(N);
x2=[x2 zeros(1,N-n2)];
 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;
 end
 r=[c]*[x2']
 %plotting magnitude and angle
subplot(211)
stem(abs(r));
title('DFT-absolute value');
subplot(212)
stem(angle(r));
title('DFT-angle');
 
OUTPUT WAVEFORM 

10 comments:

  1. Replies
    1. This comment has been removed by the author.

      Delete
    2. just to initialise the array by zero. we need it to create memory

      Delete
    3. why we initialise array by zero and why create memory

      Delete
  2. Kindly tell what to enter in the answer when it asks for "enter the sequence" and what is its function?
    Kindly if you can explain this program briefly. Waiting for your reply.

    ReplyDelete
  3. If you want a four point DFT, you will enter 4 values ,say, 2 3 4 6.

    ReplyDelete
  4. if I want to find DFT for square form
    How do I exchange

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. How can I change the quantity of samples?

      Delete