Sunteți pe pagina 1din 7

De La Salle University Electronics and Communications Engineering Department Discrete-time Systems Laboratory Experiment 3 I. Objectives : [1.

] To use the MATLAB function filter in implementing the difference equation of a linear time-invariant system. [2.] To compare the output of a linear-time invariant system computed using the convolution sum with the difference equation. [3.] To use a pre-defined filter coefficients in filtering a tone. [4.] To derive the impulse response of an LTI system using the partial fraction expansion function of matlab. II. Introduction Linear Time-Invariant System Consider a system whose input/output relation is:

x[n]

H{x[n]}

y[n]

The output of a linear and time-invariant system is defined as the convolution sum of an impulse response, h[n], and the input sequence x[n] as given below:

In Matlab, the convolution can be obtained using the function conv. Below is a function that computes the convolution of two sequences and their corresponding time in indexes.

Example: Determine the convolution of the following sequences

Impulse Response 0.5

-0.5

10 Input

15

20

25

0.5

10 Output

12

14

16

18

20

1 0.5 0 -0.5 0 5 10 15 20 25 30 35 40 45

Difference Equation A causal linear time-invariant system can also be characterized by a linear constantcoefficient difference equation:

where N is the order of the system. A recursive system is a discrete-time system whose output is determined by the weighted sum of past output samples as well as past and/or present input samples. A non-recursive system is a discrete-time system for which the output samples are determined by the weighted sum of past and present input samples only. In matlab the output of a difference equation is obtain by using the matlab function filter. The input arguments of the matlab function filters are the following:

Where L is the number of samples of the input sequence. The output sequence, y, can be obtained using the following matlab expression: y=filter(b,a,x) Conversion of Impulse Response to Difference Equation The difference equation of an LTI system can be determined from the impulse response using the convolution theorem and Transfer Function. The transfer function of an LTI system is given by:

The z-transform of the impulse response is basically the transfer function

Shown below are the common transform pairs. Discrete-time Signal x[n] [n] Z-Transform X(z) 1 Region of Convergence ROC all z
z >1 z > a z > a z < a z < a z >1 z >1 z > a z > a

u[n] a n u[n] na n u[n] a u[n 1] na n u[n 1] cos(o n )u[n] sin (o n )u[n]


a n cos( o n )u[n] a n sin ( o n )u[n]
n

1 1 z 1 1 1 az 1 az 1

(1 az )
1 1 az 1 az 1

1 2

(1 az )

1 2

1 cos( o )z 1 1 2 cos( o )z 1 + z 2 sin ( o )z 1 1 2 cos( o )z 1 + z 2


1 a cos( o )z 1 1 2a cos( o )z 1 + a 2 z 2 a sin ( o )z 1 1 2a cos( o )z 1 + a 2 z 2

Transfer Function to Impulse Response


Conversion from the filter coefficients to impulse response in Matlab can be achieved using the following techniques: 1. Unit Impulse Sequence In the unit impulse sequence is applied to the filter whose parameters are defined in the vectors a and b. The output of the filter corresponds to the impulse response N=25; x=[1 zeros(1,N-1)]; h=filter(b,a,x); 2. Partial Fraction Expansion In the partial fraction expansion, the expanded form is obtained by using the matlab function residue. [R,P,K] = RESIDUE(B,A) finds the residues, poles and direct term of a partial fraction expansion of the ratio of two polynomials B(z)/A(z) B( z ) R (1) R (2 ) R (n ) = + +L+ + K (z ) A( z ) z P (1) z P (2 ) z P(n ) Example: Determine the inverse z-transform

X (z ) =
Define b and a:

1 1 1 .5 z + 0 .5 z 2
1

ROC z > 1

b = [1] a = [1 1.5 0.5] POLES-ZERO plot of X(z) can be obtained by using the matlab function zplane: zplane (b,a)
1 0.8 0.6 0.4 Imaginary Part 0.2 0 -0.2 -0.4 -0.6 -0.8 -1 -1 -0.5 0 Real Part 0.5 1 2

Figure 2. POLES-ZERO plot

Partial Fraction Expansion X (z ) z = 2 z z 1 .5 z + 0 .5 Define B and A B = [1 0] A = [1 1.5 0.5] Partial Fraction using Matlab: [R,P,K]=residue(B,A)

2 1 R = P = k =[ 1 0 .5
Partial Fraction Expansion X (z ) = Discrete-time sequence

R (1)z R (2 )z 2z z + = z P (1) z P (2 ) z 1 z 0.5

x[n] = 2u[n] ( 1 ) u[n] 2


n

Two Dimensional Digital Filtering


For two-dimensional signal such as picture signal, filtering can be achieved using the matlab function filter2. As an example, consider a two dimensional low pass filter given by:

The output of an FIR filter whose input image,x, is shown in figure 3a is obtain as follows: y=filter(n,x ,same) The resulting image is shown in figure 3b.

III. Exercises 1. Using the partial fraction expansion function in Matlab, determine the impulse responses (h1,h2,h3,h4) of the following systems by plotting their impulse responses for n = 0 to 24 in figure 1
1.1 y[n] + 0.13 y[n 1] + 0.52 y[n 2] + 0.3 y[n 3] = 0.16 x[n] 0.48 x[n 1] + 0.48 x[n 2] 0.16 x[n 3] 1.2 y[n] 0.268 y[n 2] = 0.634 x[n] 0.634 x[n 2] 1.3 y[n] + 0.268 y[n 2] = 0.634 x[n] + 0.634 x[n 2] 1.4. 10 y[n] 5 y[n 1] + y[n 2] = x[n] 5 x[n 1] + 10 x[n 2]

2. For the systems given in number 1, determine the impulse responses (g1,g2,g3,g4) using the Matlab function filter with an input sequence equal to the unit impulse sequence 3. Generate a sum of two sinusoidal signals shown below:

For n = 0 to 149. Shown below is a notch filter that will reject one of the tones in x[n]. Apply the signal x[n] to the notch filter and determine the resulting output sequence y[n]. Plot the sequence x[n] and y[n] in figure 2.

4. Using the following filters, determine the resulting images I1, I2, and I3 using the following convolution kernels. Use lena_gray.tiff as the input image. The size of the output image should be the same as the input image. Plot the input image and output images in figure 3.

S-ar putea să vă placă și