Escolar Documentos
Profissional Documentos
Cultura Documentos
%Author:Arun P S
%Date:2/7/2015
clc
clear all
close all
for k=1:N
for n=1:N
w(k,n)=exp(-j*2*pi*(n-1)*(k-1)/N);
end
end
Xk=w*xnew';
f=0:N-1;
subplot(221)
stem(f,xnew)
xlabel('n--->')
ylabel('x(n)')
title('Input sequence with zeros appended')
subplot(222)
stem(f,abs(Xk))
xlabel('k--->')
ylabel('X(k)')
title('Magnitude plot of DFT without using fft() ')
subplot(223)
stem(f,angle(Xk))
xlabel('k--->')
ylabel('angle (X(k)) in radians')
title('Phase plot of DFT without using fft() ')
for n=1:N
for k=1:N
winv(n,k)=exp(j*2*pi*(n-1)*(k-1)/N);
end
end
xcap=winv*Xk/N;
subplot(224)
stem(f,xcap);
xlabel('n--->')
ylabel('xcap(n)')
title('Input sequence recovered without using ifft() ')
Xk=fft(x,N);
figure
subplot(221)
stem(f,xnew)
xlabel('n--->')
ylabel('x(n)')
title('Input sequence with zeros appended')
subplot(222)
stem(f,abs(Xk))
xlabel('k--->')
ylabel('X(k)')
title('Magnitude plot of DFT using fft() ')
subplot(223)
stem(f,angle(Xk))
xlabel('k--->')
ylabel('angle (X(k)) in radians')
title('Phase plot of DFT using fft() ')
xcap=ifft(Xk,N);
subplot(224)
stem(f,xcap);
xlabel('n--->')
ylabel('xcap(n)')
title('Input sequence recovered using ifft() ')
Input sequence with zeros appended Magnitude plot of DFT without using fft()
5 15
10
3
X(k)
x(n)
2
5
0 0
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
n---> k--->
Phase plot of DFT without using fft() Input sequence recovered without using ifft()
3 5
2 4
angle (X(k)) in radians
1 3
xcap(n)
0 2
-1 1
-2 0
-3 -1
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
k---> n--->
Input sequence with zeros appended Magnitude plot of DFT using fft()
5 15
10
3
X(k)
x(n)
2
5
0 0
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
n---> k--->
Phase plot of DFT using fft() Input sequence recovered using ifft()
3 5
2 4
angle (X(k)) in radians
1 3
xcap(n)
0 2
-1 1
-2 0
-3 -1
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
k---> n--->
Observations:
Result
DFT and IDFT of the given sequence have been computed and plotted, with and without using built in
function.