Programs for digital signal processing. written using MATLAB
Pages
Showing posts with label Fourier transform. Show all posts
Showing posts with label Fourier transform. Show all posts
MATLAB program to find DFT and IDFT using matlab functions
Program Code
%DFT and IDFT using matlab functionsclc;
close all;
clear all;
x=input('Please enter the sequence x(n)=');
N=input('Please enter the length of the DFT N=');
X=fft(x,N);
n=0:length(x)-1;
subplot(311);
stem(n,x);
title('Input Sequence');
subplot(323);
n=0:length(X)-1;
stem(n,X);
disp('DFT of input sequence is ');
disp(X);
title('DFT');
subplot(324);
stem(n,abs(X));
title('Magnitude spectrum');
subplot(325);
stem(n,angle(X));
title('Phase spectrum');
xr=ifft(x,N);
subplot(326);
stem(n,abs(xr));
title('IDFT');
disp('IDFT of input sequence is ');
disp(xr);
Example of Output
Please enter the sequence x(n)=[1 2 3 4 5 6 7 8 9]Please enter the length of the DFT N=6
DFT of input sequence is
Columns 1 through 4
21.0000 + 0.0000i -3.0000 + 5.1962i -3.0000 + 1.7321i -3.0000 + 0.0000i
Columns 5 through 6
-3.0000 - 1.7321i -3.0000 - 5.1962i
IDFT of input sequence is
Columns 1 through 4
3.5000 + 0.0000i -0.5000 - 0.8660i -0.5000 - 0.2887i -0.5000 + 0.0000i
Columns 5 through 6
-0.5000 + 0.2887i -0.5000 + 0.8660i
______________________________
Labels:
b.tech,
dft,
digital signal processing,
dsp,
Fourier transform,
idft,
ktu,
matlab
Subscribe to:
Posts (Atom)