Digital Signal Processing using Matlab 5.3
     <<Home  Lab 4
   

 Transform techniques are an important tool in the analysis of signals and LTI (Linear Time Invariant) systems.


 Z-transform is an infinite power series, it exists only for those values of z for which this series converges (where z is complex variable) .The ROC (Region of convergence) of X(z) is the set of all values of z for which X(z) attains a finite value.


 Inverse Z-transform can be obtained by transforming the z-domain to the time domain.

 Following two methods are used for finding inverse z-transform in this lab

(a) Partial fraction method            (b) Power series method.


 Z- transform is applied for discrete time signals and LTI systems.

 Laplace transform is applied for continuous-time signals and LTI systems.


 The roots of the denominator of H(z) are called "poles" and those of the numerator are called "zeros"

 

Note:- The signal decays if the pole is inside the unit circle, and grows if the pole is outside the unit circle.

            A negative pole results in a signal that alternates in sign.

            Signals with poles outside the unit circle become unbounded, cause overflow in digital systems, this

            should be avoided.

            If all poles lie inside of a unit circle on the z-plane means discrete time LTI system is stable.

Z-transform                                                                                                                               

                                                                                                                                                 

Example 1                                                                                                                                 

 Find the poles and zeros of the following pulse transfer function and plot them onto the z plane.       

H(z) = (2-z-1) / (1-0.1z-1 - 0.02z-2)

Matlab algorithm is as follows

 Solution                                                                                                                                    

  num =[2 -1]           

  den = [1 -0.1 -.02] 

  poles =roots(den)   

  zeroes = roots(num)

  zplane(num,den)   

  grid

 Result                                                                                                                                       

                                  

poles = 0.2000,  -0.1000
zeroes = 0.5000

 

Q. Is this system stable? Why?

Ans. Yes the system is stable, since all of its poles lie inside of unit circle on the z-plane as shown in above figure.

Z-transform                                                                                                                               

                                                                                                                                                 

Exercise 1                                                                                                                                   

 Repeat example 1 for

H(z) = (2.25-2.1z-1-3.95z-2 -1.6z-3 -0,2z-4) / (4-2.96z-1 +0,8z-2 -0,118z-3 -0,0064z-4)

 Solution                                                                                                                                    

  num =[2.25 -2.1 -3.95 -1.6 -0.2]           

  den = [4 -2.96  -0.8 -0.118 -0.0064] 

  poles =roots(den)   

  zeroes = roots(num)

  zplane(num,den)   

  grid

 Result                                                                                                                                       

                                  

poles =  0.9773,  -0.0750  + 0.1147i,  -0.0750 - 0.1147i,  -0.0872
zeroes = 2.0000,  -0.4000,  -0.3333,  -0.3333

 

Q. Is this system stable? Why?

Ans. Yes the system is stable, since all of its poles lie inside of unit circle on the z-plane as shown in above figure.

Inverse Z-transform                                                                                                                   

                                                                                                                                                 

Example 2     (Practice on Partial fraction)                                                                                  

 Use MATLAB determine the partial fraction expansions of

 H(z) = 18z3 / (18z3 +3z2 -4z -1)

 Solution                                                                                                                                    

  num = [18 0 0 0];

  den = [18 3 -4 -1];

  [r,p,k] = residuez(num,den);

  disp('Residues'); disp(r')

  disp('Poles'); disp(p')

  disp('Constants'); disp(k)

 Result                                                                                                                                       

  Residues
              0.3600   0.2400   0.4000
  Poles
              0.5000   -0.3333   -0.3333
  Constants
              0

 

 Therefore

  H(z) = 0.24/(1+0.333z-1) + 0.4/(1+0.333z-1)2 + 0.36/(1-0.5z-1)

Inverse Z-transform                                                                                                                   

                                                                                                                                                 

Example 3     (Practice on Power series method)    using impz function                                        

Determine the inverse Z-transform of

(1+2z-1)/(1+0.4z-1 -0.12z-2)

 Solution                                                                                                                                    

   L = 11; % Length of output vector (How may values you want in output)

   num = [1 2];

   den = [1 0.4 -0.12];

   [y,t] = impz(num,den,L);

   disp('Coefficient of the power series expansion '); disp(y')

 Result                                                                                                                                        

Coefficient of the power series expansion

1.0000  1.6000  -0.5200  0.4000  -0.2224  0.1370  -0.0815  0.0490  -0.0294  0.0176  -0.0106

Inverse Z-transform                                                                                                                   

                                                                                                                                                 

Example 4     (Practice on Power series method)    using filter function                                        

 Repeat example 3 with the built-in function "filter"

 Solution                                                                                                                                    

   t=0:1:10;

   L = 11; % Length of output vector (How may values you want in output)

   num = [1 2];

   den = [1 0.4 -0.12];

   x=[1,zeros(1,L-1)];

   y=filter(num,den,x);

   disp('Coefficient of the power series expansion are'); disp(y)

   stem(t,y)

   grid

 Result                                                                                                                                        

                                 

Coefficient of the power series expansion

1.0000  1.6000  -0.5200  0.4000  -0.2224  0.1370  -0.0815  0.0490  -0.0294  0.0176  -0.0106

Inverse Z-transform                                                                                                                   

                                                                                                                                                 

Example 4b     (Practice on Power series method)    using decov function                                   

 Repeat example 3 with the built-in function "deconv"

 Solution                                                                                                                                         num = [1 2];

   den = [1 0.4 -0.12];

   y=deconv(den,num);  

   disp('Coefficient of the power series expansion are'); disp(y)

 Result                                                                                                                                        

Coefficient of the power series expansion

1.0000  -1.6000

Impulse and Step response                                                                                                        

                                                                                                                                                 

Exercise                                                                                                                                    

 Plot impulse and Step response of the transfer functions of example1 and  example 3. Also try the  built in function filter to plot the same response. 

 Solution                                                                                                                                    

    % Impulse response of example 3 by dimpulse function

    L = 11;

    num = [1 2];

    den = [1 0.4 -0.12];

    dimpulse(num,den)

 Result                                                                                                                                        

                                   

 Solution                                                                                                                                          % Step  response of example 3 by dstep function

    L = 11;

    num = [1 2];

    den = [1 0.4 -0.12];

    dstep(num,den)

 Result                                                                                                                                        

                                   

 Solution                                                                                                                                      

    %exercise impulse and step response by filter function of example 1

    L=11

    t=0:1:10;

    num =[2 -1];

    den = [1 -0.1 -.02];

    % Impulse response

    x=[1, zeros(1,L-1)];

    y=filter(num,den,x);

    stem(t,y)

    % step response

    figure;

    a=ones(L);

    b=filter(num,den,a);

    stem(t,b)

 Result                                                                                                                                        

                                                                                   Impulse response

                                  


                                                                   Step response

                             

Frequency response                                                                                                                  

                                                                                                                                                 

Example                                                                                                                                    

Sketch the normalized frequency response of the system having the pulse transfer function:

H(z) = (1+0.95z-1)/(1-1.8z-1+0.81z-2)

 Solution                                                                                                                                      

   num=[1 0.95];

   den=[1 -1.8 0.81];

   w= -pi:pi/255:pi;

   h=freqz(num,den,w);

   h1=abs(h);

   h2=h1/(max(h1));

   h3=20*log10(h2);

   figure

   plot(w,h3);

 Result                                                                                                                                          

                          

Frequency response                                                                                                                  

                                                                                                                                                 

Exercise                                                                                                                                    

Repeat the above example for the following system:

 (1+z-1)/(1+0.1z-1+0.2z-1)

Comment on the response. Find and sketch poles, zeros, step response, impulse response and ramp response of the system.

 Solution                                                                                                                                      

   num=[1 1];

   den=[1 0.1 -0.2];

   poles=roots(den)

   zeroes=roots(num)

   zplane(num,den)

   grid

 

   figure

   dimpulse(num,den)

   figure

   dstep(num,den)

   %ramp response

   n=0:1:10;

   x=n;

   y=filter(num,den,x);

   figure

   plot(n,y)

 Result                                                                                                                                          

                            

poles = -0.5000 0.4000
zeroes = -1

                            

                            

                                                                 Ramp Response

                            

Frequency response                                                                                                                  

                                                                                                                                                 

Exercise                                                                                                                                    

 Sketch the magnitude and phase response of H(z) = 1/ (1-0.8z-1)

 Solution                                                                                                                                        num=[1];

   den=[1 -0.8];

   w= -pi:pi/255:pi;

   h=freqz(num,den,w);

   h1=abs(h);

   h2=h1/(max(h1));

   h3=20*log10(h2);

   figure

   plot(w,h3);

 

%this is for the Phase Response

   h4=angle(h); %since phase cannot be in DB so no h2 and h3

   figure

   plot(w,h4)

 Result                                                                                                                                          

                                                            Magnitude Response

                            

                                                                Phase Response

                            

 HELP                                                                                                                                       

 ROOTS                                                                                                                                    

 ROOTS Find polynomial roots.
ROOTS(C) computes the roots of the polynomial whose coefficients are the elements of the vector C. If C has N+1 components, the polynomial is C(1)*X^N + ... + C(N)*X + C(N+1).

ZPLANE                                                                                                                                   
 ZPLANE Z-plane zero-pole plot.
ZPLANE(Z,P) plots the zeros Z and poles P (in column vectors) with the  unit circle for reference. Each zero is represented with a 'o' and  each pole with a 'x' on the plot.

 RESIDUEZ                                                                                                                             

 RESIDUEZ Z-transform partial-fraction expansion.
[R,P,K] = RESIDUEZ(B,A) finds the residues, poles and direct terms of the partial-fraction expansion of B(z)/A(z),

B(z)         r(1)                    r(n)
---- = ------------ +... ------------ + k(1) + k(2)z^(-1) ...
A(z) 1-p(1)z^(-1) 1-p(n)z^(-1)

B and A are the numerator and denominator polynomial coefficients, respectively, in ascending powers of   z^(-1). R and P are column vectors containing the residues and poles, respectively. K contains the direct terms in a row vector. The number of poles is
n = length(A)-1 = length(R) = length(P)
The direct term coefficient vector is empty if length(B) < length(A);
otherwise,
length(K) = length(B)-length(A)+1

 DISP                                                                                                                                         

DISP Display array.
DISP(X) displays the array, without printing the array name. In all other ways it's the same as leaving the semicolon off an expression except that empty arrays don't display.
If X is a string, the text is displayed.

 IMPZ                                                                                                                                       

IMPZ Impulse response of digital filter
[H,T] = IMPZ(B,A) computes the impulse response of the filter B/A
choosing the number of samples for you, and returns the response in column vector H and a vector of times (or sample intervals) in T
(T = [0 1 2 ...]').

[H,T] = IMPZ(B,A,N) computes N samples of the impulse response.
If N is a vector of integers, the impulse response is computed only at those integer values (0 is the origin).

[H,T] = IMPZ(B,A,N,Fs) computes N samples and scales T so that samples are spaced 1/Fs units apart. Fs is 1 by default.

[H,T] = IMPZ(B,A,[],Fs) chooses the number of samples for you and scales T so that samples are spaced 1/Fs units apart.

IMPZ with no output arguments plots the impulse response using STEM(T,H) in the current figure window.

 FILTER                                                                                                                                   

 FILTER One-dimensional digital filter.
Y = FILTER(B,A,X) filters the data in vector X with the filter described by vectors A and B to create the filtered data Y. The filter is a "Direct Form II Transposed" implementation of the standard difference equation:

a(1)*y(n) = b(1)*x(n) + b(2)*x(n-1) + ... + b(nb+1)*x(n-nb)
- a(2)*y(n-1) - ... - a(na+1)*y(n-na)

If a(1) is not equal to 1, FILTER normalizes the filter coefficients by a(1).

When X is a matrix, FILTER operates on the columns of X. When X is an N-D array, FILTER operates along the first non-singleton dimension.

[Y,Zf] = FILTER(B,A,X,Zi) gives access to initial and final conditions, Zi and Zf, of the delays. Zi is a vector of length MAX(LENGTH(A),LENGTH(B))-1 or an array of such vectors, one for each column of X.

FILTER(B,A,X,[],DIM) or FILTER(B,A,X,Zi,DIM) operates along the dimension DIM.

 DECOV                                                                                                                                   

 DECONV Deconvolution and polynomial division.
[Q,R] = DECONV(B,A) deconvolves vector A out of vector B. The result is returned in vector Q and the remainder in vector R such that  B = conv(A,Q) + R.
If A and B are vectors of polynomial coefficients, deconvolution is equivalent to polynomial division. The result of dividing B by A is quotient Q and remainder R.

 DIMPULSE                                                                                                                                                                     

 DIMPULSE(NUM,DEN) plots the impulse response of the polynomial transfer function G(z) = NUM(z)/DEN(z) where NUM and DEN contain the polynomial coefficients in descending powers of z.

 DSTEP                                                                                                                                     

 DSTEP(NUM,DEN) plots the step response of the polynomial transfer function G(z) = NUM(z)/DEN(z) where NUM and DEN contain the polynomial coefficients in descending powers of z.

 FREQZ                                                                                                                                       

 FREQZ Digital filter frequency response.
[H,W] = FREQZ(B,A,N) returns the N-point complex frequency response vector H and the N-point frequency vector W in radians/sample of the filter:
                  jw                      -jw                    -jmw
       jw  B(e)    b(1) + b(2)e + .... + b(m+1)e
H(e) =  ---- = ------------------------------------
                  jw                     -jw                   -jnw
            A(e)    a(1) + a(2)e + .... + a(n+1)e
given numerator and denominator coefficients in vectors B and A. The frequency response is evaluated at N points equally spaced around the upper half of the unit circle. If N isn't specified, it defaults to 512.

[H,W] = FREQZ(B,A,N,'whole') uses N points around the whole unit circle.

H = FREQZ(B,A,W) returns the frequency response at frequencies designated in vector W, in radians/sample (normally between 0 and pi).

[H,F] = FREQZ(B,A,N,Fs) and [H,F] = FREQZ(B,A,N,'whole',Fs) given a sampling freq. Fs in Hz return a frequency vector F in Hz.

H = FREQZ(B,A,F,Fs) given sampling frequency Fs in Hz returns the complex frequency response at the frequencies designated in vector F, also in Hz.


DSP Lab 1   DSP Lab2   DSP Lab 3   DSP Lab4   DSP Lab 5   DSP Lab 6   DSP Lab7  DSP Lab8  DSP Lab9  DSP Lab10   DSP Lab 11  Other material


   
 
                                                                                                                   <<Home
  
Ziauddin Siddiqui, B02ME CSN 07, Mehran University Of Engineering & Technology
Jamshoro, Sindh.
Email. [email protected]

1