Lingayas University, Faridabad(D eem to be University u/s 3 of UGC Act 1956) ed
Par Excellence w ith Hum Touch an
M. Tech. Degree Programme Term II
DIGITAL SIGNAL PROCESSING (EC-552)
PRACTICAL NOTE BOOK
Name
: SUDHIR KUMAR JHA Branch : ECE
Roll No. :10PGECPT21
Group : TERM- II Session : 2010 2011.
LIST OF EXPERIMENT 1. Write a program to represent basic signals (unit step, unitimpulse ramp, Exponential, sine & cosine)
2. Write a Program for computing inverse Z-transform of arational transfer function
3. To develop program for linear convolution and circularconvolution
4. Write a Program for plotting the frequency response of firstorder System.
5. Write a Program for computing Discrete Fourier Transform(DFT).
6. Design a Butterworth Low pass IIR filter using Bilinear Ztransform method.
7. Design FIR Low pass filter and High pass filter usingRectangular window
8. Transform an analog filter in to a digital filter using ImpulseInvariant method
9. Design a Chebyshev Low pass filter. 10. Design FIR low pass filter using Kaiser Window
EXPERIMENT NO.-1AIMWrite a program to represent basic signals (unit step, unit impulse ramp, exponential, sine & cosine)
REQUIREMENTMATLAB Software
THEORYSingularity functions are an important classification of non-periodic signal. They can be used to represent more complicated signal. Some of them are unit impulse function, step function, ramp function. 1. Unit Impulse Function is defined as :.
, 1 otherwise2. Unit Sep Function is defined as :-
3.
Unit Ramp Function is defined as :-
4.
Exponential Sequencex( n ) = Ar n
PROGRAM
EXPERIMENT NO. 2AIMWrite a Program for computing inverse Z-transform of a rational transfer function.
REQUIREMENTMATLAB Software
THEORYMathematically, the inverse z-transform is expressed asx( n ) = z 1 [ x( z ) ]
Methods as under: (1) Long Division Methodx( z ) = x( n ) z nn =0 N ( z) = an z n D ( z ) n =0
x( z ) =
(2)
Partial fraction methodH ( z) = a0 z m + a1 z m1 + a2 z m2 + ...... + am ( z P1 ) ( z P2 ) .............( z Pn ) An A1 A2 + + ........ + Z P1 ( z P2 ) ( z Pn )n 1
OrH ( z ) = A0 +
(3)
Residues Methodx( n ) =all poles x z
residues of [ x( z ) z ] ( )
Lim d m1 1 m n 1 Re sidues = m1 C ( z ) ( z ).z ( m 1)! z d 2
[
]
PROGRAM
%Consider the Z- Transform %z/(3*z^2 - 4*z +1).% Find inverse ZTransform b = [0 1]; a = [3 -4 1]; [R P C] = residuez(b, a)
RESULTR = .5000 -.5000 P = 1.000 0.3333 C = [] R = Residue P = pole C = Direct term of a pf expansion.
EXPERIMENT NO. 3AIM To develop program for linear convolution and circular convolution. REQUIREMENTMATLAB Software
THEORYCONVOLUTION:It is a powerful way of characterizing the input-output relationship of time invariant linear system. There are two-convolution theorem, one for the time domain and another for frequency domain. Convolution of one signal in time domain is equal to multiplication of their individual Fourier transform in frequency domain.
(1) (2)
Convolution of two discrete time signals x1 (n) and x2(n) is x(n) = x1(n) x2(n) = Circular Convolution X(n) = x1(n) x2(n) =k =
x1(k ) x 2(n k ) x1(k ) x 2(n k )
k =
PROGRAM Program for linear convolution and circular convolution close all; clear all; x = [2 1 3 1 2 4]; h = [1 2 1 2 3 1 1 ]; y=conv(x,h); z=cconv(x,h); subplot(5,1,1); stem(x); xlabel('figure(a) n'); ylabel('Amplitude'); title('first sequence'); subplot(5,1,2); stem(h); xlabel('figure(b) n'); ylabel('Amplitude'); title('second sequence'); subplot(5,1,3); stem(y); xlabel('figure(c) n'); ylabel('Amplitude'); title('Linear convolution'); subplot(5,1,4); stem(z); xlabel('figure(d) n'); ylabel('Amplitude'); title('circular convolution'); disp(y); disp(z);
ResultAmplitude Amplitude first sequence 4 2 0 1 2 3 4 figure(a) n second sequence 3 4 5 figure(b) n Linear convolution 6 8 figure(c) n circular convolution 6 figure(d) 8 n 5 6
4 2 0
1
2
6
7
Amplitude Amplitude
40 20 0
0
2
4
10
12
40 20 0
0
2
4
10
12
EXPERIMENT NO.-4AIM Write a Program for plotting the frequency response of first order system. REQUIREMENTMATLAB Software THEORY
The transfer function of a first order system is given by: H(z)= B(z)/ A(z) Here the highest power of numerator and denominator is one since it is a first order system. This block assumes that the transfer function has the following form where u and y are the system's input and outputs, respectively, nn and nd are the number of numerator and denominator coefficients, respectively. num and den contain the coefficients of the numerator and denominator in descending powers of z.The order of the denominator must be greater than or equal to the order of the numerator. This block also assumes that the transfer functions for the outputs of a multiple output system have the same denominator and that the numerators of the transfer functions have the same order. The Transfer Function First Order block implements a discretetime first order transfer function of the input. The transfer function has a unity DC gain.
PROGRAMb = [1]; a = [1, -.8]; w = .01:2*pi; [h] = freqz(b, a, w); subplot(2, 1, 1); plot(w/pi, abs(h)); title('Frequency Response of the first order system'); xlabel('Normalized frequency'); ylabel('Magnitude'); subplot(2, 1, 2); plot(w/pi, angle(h)); xlabel('Normalized Frequency'); ylabel('Phase in Radian');
Frequency Response of the first order system 5 4 Magnitude 3 2 1 0 0 0.5 1 Normalized frequency 1.5 2
1 Phase in Radian 0.5 0 -0.5 -1 0 0.5 1 Normalized Frequency 1.5 2
EXPERIMENT NO. 5AIM Write a Program for computing Discrete Fourier Transform (DFT). REQUIREMENTMATLAB Software THEORY It is a finite duration discrete frequency sequence which is obtained by sampling one period of Fourier transform. Sampling is done at N equally spaced points over the period points over the period extending = 0 to = 2
The DFT of discrete sequence x(n) is denoted by x(h) it is given byX ( k ) = x( n ) cj 2kn / nn=0 N 1
Here k = 0, 1, 2 ..N-1 IDFT is given byx( n ) = 1 X ( k ) c j 2kn / N N
N=0, 1, 2 N-1
PROGRAM
EXPERIMENT NO. 6AIM Design a Butterworth Low pass IIR filter using Bilinear Ztransform method. REQUIREMENTMATLAB Software
THEORY
PROGRAM[b, a]= butter(20,.3,'low'); [bz, az] = bilinear(b, a, 10); freqz(bz, az, 512, 1000); title('Butterworth LPF response');
Butterworth LPF response 50 Magnitude (dB) 0 -50 -100 -150 -200 0 100 200 300 Frequency (Hz) 400 500
15000 Phase (degrees) 10000
5000
0
0
100
200 300 Frequency (Hz)
400
500
EXPERIMENT NO. 7AIM Design FIR Low pass filter and High pass filter using Rectangular window. REQUIREMENTMATLAB Software
THEORY
PROGRAM
EXPERIMENT NO. 8AIM Transform an analog filter in to a digital filter using Impulse Invariant method. REQUIREMENTMATLAB Software
THEORY
PROGRAM [b,a] = butter(4, 0.3, 'low'); [bz,az] = impinvar(b, a,10); freqz(bz, az, 512, 1000);
-10 Magnitude (dB) -20 -30 -40 -50 0 100 200 300 Frequency (Hz) 400 500
800 Phase (degrees) 600 400 200 0 0 100 200 300 Frequency (Hz) 400 500
EXPERIMENT NO. 9AIM Design a Chebyshev Low pass filter. REQUIREMENTMATLAB Software
THEORY Please see next page.
PROGRAM %Chebyshev LPF Ap = 1; As = 15; wp = .2*pi; ws = .3*pi; [n ,wn] = cheb1ord(wp/pi, ws/pi, Ap, As); [b, a] = cheby1(n, Ap, wn); w = 0 : .01 :pi; [h, ph] = freqz(b, a, w); m = 20*log10(abs(h));an = angle(h); subplot(2, 1, 1); plot(ph/pi, m); grid; ylabel('Gain in dB'); xlabel('Normalised Frequency'); subplot(2,1,2); plot(ph/pi, an); grid; xlabel('norm frq'); ylabel('phase') [b, a] = cheby1(n, Ap, wn);
EXPERIMENT NO. 10AIM Design low pass filter using Kaiser Window REQUIREMENTMATLAB Software
THEORY
PROGRAM