DSP Exp 4
DSP Exp 4
Date:/
Expenment-4
Program t8-1
subplot(2,2,2)3sten( t,nagnt tucie)
ylabel( "Anglttude" );
N tnput? Number of DFT points alabel('*
Xnnput("Enter the sequence x[n] '
titlet DrT Sequence")39rta o
tn length( xn) phasea angletDFT)3
xnxn zeros(1,N-Un)l aisp( hase
$Inttialie an array of sane stze as that of iput sequence dispiphase)s
For DFT t 0N-1
DET2eros(1,N) subplott2,2,3)sten(t,phase)
For DT ylabel("Phase );
DFT2eros( 1,N) xtabel(' )
xlint|-2 S]s
Nested for loop to find the DFT of the sequence titler Phase Response' )39rid n
$ Here, e 2st rix the k them taking sm of n tron & to N
Tor k 8:N-1 $Nested Tor lop to nas he zDT ef the saqence
torn 0:N-1 Nere, we 2st fix the a then taking suR of k fron 8 te
DFT(K+1)- DFT(K+1)+{Nxn(h+l)*exp((-11)2*pi*kn/N));| for na 0N-1
end Tor 0N-1
end LDFT2) iDFTR+2}H(OFT(K+2)*exg(212*pisk*N)
nd
t 8:N-
subplot(2,2,1);stentt,xn)3
ylabel( Anplitude' DFT DFTNG
xtabel('n') t 0:N-1s
Xtin-2 5])s subplot (2,2,4)
titlet Input Sequence );ortd ong sten(t, t0FT)S
disp( 10FT Sequence a )
nagnitude = abs(DET)S
disp('DFT Sequence ) disp( iDFT)S
disp(nagnttude ) ylabel( "Anplitude );
xlabel( °n° )3
xtintl-2 Ss])
title( 205T sequence 9rid ons
Output:
1,2, 1,0
DFTScquence
4.0000 2.0000 0 2.0000 Phase Response
Phase
-1.5708 0 1.5708
IDFT Sequence
L.0000-0.0000i 2.0000+0.0000i 1.0000+0.0000i 0.0000+0.00001
Page No.
Date:I1
N k-o
Algoi.hm=
DTake h ihput Seqh zln]
ompute IEs DE, bs uing 2 or-loops* om k=o;N-1 and 2hd
krom h D:N-
Uscd thc abole mcenhioned fapmula to Complelc in DET
ObsorNalions
We obtjned tho magnikude and phate yesponse O giyen inpo
Slono LnLie. Ifs DET.
We aso obtained ths IbET Sagh uhich it Same a ihput Signal
Ocn
Cohclusion
we haVe Succegeully obtolnedtu DET Sexh phose ond magnikodh
Yes pohse Ond Segnyon gich ihput Se (n)
DFT&iDFT with using in-built function
Program
subplot(2,2,2)1stem(t,nagnttude, 'fil, black')
N input("Number of DFT points ); ylabel('Anplitude' ))
xn input( Enter the sequence x[n] = ) ;
xlabel( 'K')
In = length(xn); xlin(-2 5))}
title DFT Sequence')
phase = angle(DFT)
For DFT e used fft() function
disp(Phase =')
DFT fft(xn) disp(phase)
For DFT he used fft() function subplot(2,2,3);sten(t,phase,'fill','black')
iDFT ifft(DFT); ylabel 'Phase')}
xlabel( 'K)
t 0:N-1 xlin(-2 5))
subplot(2,2,1);stem(t,xn,'fill,'black'); title 'Phase Response');
ylabel( Amplitude' );
xlabel( 'n');
subplot(2,2,4);stem(t, iDFT,'TiLL', 'black');
disp IDFT Sequence = ')}
xlin(-2 5] disp( iOFT);
title( Input Sequence); ylabel( 'Anplitude')
magnitude abs(DFT); Xlabel( 'n');
disp('DFT Sequence xlim-2 5]);
disp(magnitude ); title('1DFT sequence')
Output:
DFT Sequence=
6.0000 2.8284 2.0000 2.8284
Phaso Rosponse OFT e
Phase
0 2.3562 3.1416 -2.3562
1DFT Sequence
0.0000-0.0000i 1.0000 +0.00001 2.0000+0.0000 3.0000+ 0.0000