Pages

Monday, December 13, 2010

MATLAB PROGRAM TO IMPLEMENT THE PROPERTIES OF DISCRETE FOURIER TRANSFORM (DFT) - FREQUENCY SHIFT PROPERTY

%dft frequecy shift property
close all;
clear all;
N=input('how many point dft do you want?');
x1=input('enter the seq');
n2=length(x1);
c=zeros(N);
x1=[x1 zeros(1,N-n2)];
for k=1:N
    for n=1:N
        w=exp((-2*pi*i*(k-1)*(n-1))/N);
        x(n)=w;
    end
    c(k,:)=x;
end
disp('dft is ');
r=c*x1';
a1=input('enter the amount of shift in frequency domain');
for n=1:N
    w=exp((2*pi*i*(n-1)*(a1))/N);
    x2(n)=w;
end
r1=x2.*x1;
subplot(221);
stem(abs(r));
grid on;
title('orginal dft magnitude plot');
subplot(222);
stem(angle(r));
grid on;
title('orginal dft angle');
for k=1:N
    for n=1:N
        w=exp((-2*pi*i*(k-1)*(n-1))/N);
        x(n)=w;
    end
    c(k,:)=x;
end
disp('dft is');
r2=c*r1';
subplot(223);
stem(abs(r2));
grid on;
title('shifted dft magnitude');
 subplot(224);
 stem(angle(r2));
 grid on;
 title('shifed dft angle');

 
OUTPUT WAVEFORM

 

 

5 comments:

  1. %Discrete time fourier transform
    k=0:500;
    x=((.5).^n).*heaviside(n);
    m=length(k)-1; w=(pi/500)*k;
    X=x*(exp(-j*pi/m)).^(n'*k);
    magX=abs(X);angX=angle(X);
    realX=real(X);imagX=imag(X);
    subplot(2,2,1);
    plot(w/pi,magX);
    grid
    xlabel('frequency in pi units');
    title('magnitude part');
    ylabel('magnitude');
    subplot(2,2,3);
    plot(w/pi,angX);grid
    xlabel('frequency in pi units');
    title('angle part');
    ylabel('angle');
    subplot(2,2,2);
    plot(w/pi,realX);grid
    xlabel('frequency in pi units');
    title('real part');
    ylabel('real');
    subplot(2,2,4);
    plot(w/pi,imagX);grid
    xlabel('frequency in pi units');
    title('imaginary part');
    ylabel('imaginary');

    ReplyDelete
  2. %magnitude & phase responce by hafiz from comsats lahore
    k=501;
    num=[1];
    den=[1 -.5];
    w=0:pi/k:pi;
    h=freqz(num,den,w);
    subplot(221)
    plot(w/pi,real(h))
    grid
    title('Real part')
    xlabel('Normalized')
    ylabel('amplitude')
    subplot(222)
    plot(w/pi,imag(h))
    grid
    title('imaganary part')
    xlabel('norm angular frequency')
    ylabel('amplitude')
    subplot(223)
    plot(w/pi,abs(h))
    grid
    title('magnitude apecturm')
    xlabel('norm angular frequency')
    ylabel('magnitude')
    subplot(224)
    plot(w/pi,angle(h))
    grid
    title('phase specturm')
    xlabel('norm angular frequency')
    ylabel('phase,radian')

    ReplyDelete
  3. i want matlab code for fs=10khz,f1=100,f2=500,a=1 code for frequency shifting ,time shiftingconvolution
    plz any one can help me

    ReplyDelete