MATLAB CODE TO FIND OUT THE DFT & IDFT THEN PLOT MANITUDE AND PHASE RESPONSE OF IT

CODE:
clc;
clear all;
close all;
x=input('enter the data sequence');
N=input('enter the N point DFT');
fs=input('enter the sample freq.');
Y=fft(x,N)                       %this will give DFT
f=fs/N;
G=ifft(Y,N)                      %this will give IDFT
z=0:f:((length(Y)-1)*f);          %freq vextor for the x axis


 subplot(2,1,1);                  %divides the current figure into numbered rowwise
stem(z,abs(Y));
title('magnitude response');
xlabel('freq');                  %give label to x axies
ylabel('Ampllitude');
 subplot(2,1,2);
p=angle(Y);                       %find out the angle          
stem(z,p*180/pi);                %Plot discrete sequence data
title('phase response');                                                 
xlabel('freq');    

ylabel('angle');     

OUTPUT:

enter the data sequence[2 0 0 1]
enter the N point DFT4
enter the sample freq.20
Y =
 3.0000             2.0000 + 1.0000i   1.0000             2.0000 - 1.0000i
G =
2     0     0     1   


0 comments:

Post a Comment