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
______________________________
what is 311,323,324,325,326
ReplyDeleteRespected Sir,
ReplyDeletesubplot(311) divides the picture window into thee equal parts and plots the output in one of the three parts.
Here 311 denotes the number of division we make in the picture window of matlab and the division in which the output appear. Similarly 323,324,325 and 326 denotes the number of division we make in the picture window of matlab and the division in which the output appear.
Thank you for spending your valuable time to visit my simple blog. Please visit my blog again. Wish you all success in life
can u pls explain the whole program
ReplyDeleterohitrajrock1@gmail.com
nice code
ReplyDeleteRespected Sir,
DeleteThank you very much for saying a few kind words about my code. Thank you very much for spending your valuable time to visit this humble blog of mine. I am always at your service. You are always welcome to visit this blog http://s5electronicsandcommunication.blogspot.com .
I wish you happiness, success and good health. I wish your friends and your family happiness, success and good health. Please share the URL of this blog http://s5electronicsandcommunication.blogspot.com with your friends.
is the code same for sequence [j j -j -j]?
ReplyDeletewhat will be the changing in the code