20
INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name , Class&Student ID Aim 1. To give student an introduction to basic MATLAB concepts. You are required to produce basic program, learn basic calculation and get familiar with MATLAB work environment. 2. To know how to generate basic signals and functions, such as square and sinc. You are required to produce programs and compare them with each other. Introduction 1. MATLABs basic operation 1) The best way to get start with MATLAB is to learn how to handle matrices. Usually, MATLAB thinks of everything as a matrix, which is a rectangular array of numbers. To enter a matrix, simply type: A=[1 2 3; 4 5 6; 7 8 9;] Then, MATLAB will display the matrix you just entered. 2) The transpose operation is denoted by an apostrophe or single quote, ' . It flips a matrix about its main diagonal and it turns a row vector into a column vector. 3) Concatenation is the process of join small matrices to make bigger ones. The pair of square bracket, [ ], is the concatenation operator. For example, start with the above 3*3 matrix A, B=[A A+1], the result B is a 3*6 matrix: B=[1 2 3 2 3 4; 4 5 6 5 6 7; 7 8 9 8 9 10] 4) , and ; are used to indicate the end of a sentence. If you type A=[1 2 3; 4 5 6; 7 8 9;], or A=[1 2 3; 4 5 6; 7 8 9;]; MATLAB wont display the matrix you just entered. If you type A=[1 2 3; 4 5 6; 7 8 9;] MATLAB will display the matrix you just entered. 5) The colon, : , is one of MATLABs most important operators. It occurs in several different forms. The expression 1:10 is a row vector containing the integers from 1 to10. To obtain nonunit

INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

  • Upload
    others

  • View
    12

  • Download
    1

Embed Size (px)

Citation preview

Page 1: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

INFE 5201 SIGNALS AND SYSTEMS

Assignment 1: Introduction to MATLAB

Name , Class&Student ID

Aim

1. To give student an introduction to basic MATLAB concepts. You are required to produce basic

program, learn basic calculation and get familiar with MATLAB work environment.

2. To know how to generate basic signals and functions, such as square and sinc. You are required

to produce programs and compare them with each other.

Introduction

1. MATLAB’s basic operation

1) The best way to get start with MATLAB is to learn how to handle matrices. Usually, MATLAB

thinks of everything as a matrix, which is a rectangular array of numbers. To enter a matrix,

simply type:

A=[1 2 3; 4 5 6; 7 8 9;]

Then, MATLAB will display the matrix you just entered.

2) The transpose operation is denoted by an apostrophe or single quote, ' . It flips a matrix about

its main diagonal and it turns a row vector into a column vector.

3) Concatenation is the process of join small matrices to make bigger ones. The pair of square

bracket, [ ], is the concatenation operator. For example, start with the above 3*3 matrix A, B=[A

A+1], the result B is a 3*6 matrix:

B=[1 2 3 2 3 4; 4 5 6 5 6 7; 7 8 9 8 9 10]

4) , and ; are used to indicate the end of a sentence. If you type

A=[1 2 3; 4 5 6; 7 8 9;], or A=[1 2 3; 4 5 6; 7 8 9;];

MATLAB won’t display the matrix you just entered. If you type

A=[1 2 3; 4 5 6; 7 8 9;]

MATLAB will display the matrix you just entered.

5) The colon, : , is one of MATLAB’s most important operators. It occurs in several different

forms. The expression 1:10 is a row vector containing the integers from 1 to10. To obtain nonunit

Page 2: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

spacing, specify an increment. For example, 100:-7:50 is 100 93 86 79 72 65 58 51.

6) When you don’t specify an output variable, MATLAB uses the variable ‘ans’, short for

‘answer’, to store the results of a calculation.

7) MATLAB has some operators, such as +, -, *, ^,',( )…Please use help to find out their

meanings.

8) MATLAB provides a large number of standard elementary mathematical functions, including

abs, sqrt, exp, and sin. MATLAB also provides many more advanced functions, including Bessel

and gamma functions. For a list of the elementary mathematical functions, type help elfun. For a

list of more advanced mathematical and matrix functions, type help specfun, help elmat. Some of

the functions, like sqrt and sin, are built- in. They are part of the MATLAB core so they are very

efficient, but the computational details are not readily accessible. Other functions, like gamma and

sinh, are implemented in M-files, You can see the code and even modify it if you want.

9) Several special functions provide values of useful constants. For instance, pi is 3.14159265…, i

is imaginary unit, j is as same as i.

10) The function stem(y) plots the data sequence y as stems from the x axis terminated with

circles for the data value. Please turn to help stem for more information.

11) The function subplot Create axes in tiled positions. H = subplot (m,n,p), or subplot (mnp),

breaks the Figure window into an m-by-n matrix of small axes, selects the p-th axes for the current

plot, and returns the axis handle. The axes are counted along the top row of the Figure window,

then the second row, etc. For example,

subplot(2,1,1), plot(income)

subplot(2,1,2),plot(outgo)

plots income on the top half of the window and outgo on the bottom half.

12) You can use % to give your own comment. MATLAB won’t calculate text after %. For

example,

f=100 %Set frequency (text after % taken as comment)

13) Please use help to find out how the functions fix, plot, figure, title, xlable, ylable perform.

You can create your own matrices using M-files, which are text files containing MATLAB code.

Just create a file containing the same statements you would type at the MATLAB command line.

14) Save the file under a name that ends in .m. To access a text editor on a PC, choose Open or

New from the File menu or press the appropriate button on the toolbar.

Page 3: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

2. Two basic signals.

1) The function square(T) generates a square wave with period 2*Pi for the elements of time

vector T. square (T) is like sin(T), only it creates a square wave with peaks of +1 to -1 instead of a

sine wave.

2) The sinc function computes the mathematical sinc function for an input vector or matrix x. The

sinc function is the continuous inverse Fourier transform of the rectangular pulse of width

2 and height 1.

t

t

)sin( t 0

sinc(t) =

1 t=0

Requirements

1. Matrix calculation

1) Set A=[1 2 3;4 5 6;7 8 9;]. Please transpose A.

2) Set A=[1 2 3;4 5 6;7 8 9;]. Please calculate [A A*3].

3) Set A= [1 2 3

4 5 6

7 8 9]

B= [ 1 4 7

2 5 8

3 6 9]

Please calculate A+B.

4) Set x=[-2 0 1]' y=[-1 -1 2]'. Please calculate x’*y,y’*x and x*y'.

5) Set x=[2,0,-1]. Please calculate pi*x.

6) Generate 4 3 random matrix.

2. To generate number series

1) x=1:5

2) y=0:pi/4:pi

3) x=0:0.1:1

4) Please describe what did you find out by doing 1), 2) and 3).

5) x=(0:0.2:3.0)'; y=exp(-x).*sin(x); Please produce [x y].

3. Data calculation

1) x=[1 2 3]; y=[4 5 6]; Please calculate x+y.

2) Set A=[1 2;3 4] B=[4 3;2 1]; Please calculate A.^2, A.^B, and give theirs

meanings respectively in your report.

3) x=[1 2 3]; y=[4 5 6]; Please calculate x.*y, x.\y and y./x. Please find the

Page 4: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

difference between .\ and ./. Describe it in your report.

4. Math function

A=[1 2 3; 4 5 6] B=fix(pi*A)

Please calculate cos(pi*B).

5. Draw picture

x=0:.05:4*pi; y=sin(x);

Please use plot to draw a picture of x and y.

6. Title

Please use title, xlable, ylabel to give titles to the picture you drew just now.

7. To generate some basic signals

1) To generate square signal

Please generate a 30 Hz square wave function. The Magnitude value is 1 ; the

time interval is 0.001s; the time is from 0 to 0.25s. Please plot the square wave.

Note:

(a) Use the function square.

(b) Refer to help square for help.

(c) Set the square function y=(2*pi*30*t).

(d) Write down the result on your report.

2) Please generate sinc function

y=t

t

)sin( ; if t=0, y=1

Note:

(a) Refer to help sinc for help

(b) Use figure and plot to show your result.

(c) Write down the result on your report.

3) To generate exponential signal

Please generate x(n)= nje )2.01.0( 1010 n . Then draw x(n)’s real part,

imaginary part, magnitude part, and phase part.

Note:

(a) Use exp to produce exponential signal.

(b) Set n=[-10:1:10], alpha=-0.1+0. 2j;

(c) Use subplot and stem to show x(n)’s real part, imaginary part, magnitude

part, and phase part in a single picture. For example, stem(n,real(x)); .

(d) Please give each sub-picture a title by using title and xlabel.

(e) Analyze your results in your report.

Page 5: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

INFE 5201 SIGNALS AND SYSTEMS

Assignment 2: Fourier Transform and Linear System Models

Name , Class&Student ID

Aim

1. To review analog signal’s FT and digital signal’s DFT.

2. To get system’s frequency transform function H(jw), and solve system transform’s

roots.

3. To get an analog system’s frequency response

Introduction

1) The foundation of the Signal Processing Toolbox is the Fast Fourier Transform

(FFT), a method for computing the DFT with reduced execution time. Many of the

toolbox functions (including z-domain frequency response, some filter design and

implementation functions) incorporate the FFT. MATLAB provides the functions fft

and ifft to compute the discrete Fourier transform and its inverse, respectively. fft, with

a single input argument x, computer the DFT of the input vector or matrix. If x is a

vector, fft computers the DFT of the vector; if x is a rectangular array, fft computes the

DFT of each array column.

For example, create a time vector and signal.

t=(0:1/99:1); % time vector

x=sin(2*pi*15*t)+sin(2*pi*40*t); % signal

The DFT of the signal, and the magnitude of the transformed sequence, are then

y=fft(x); % Compute DFT of x.

m=abs(y); % magnitude

A second argument to fft specifies a number of points n for the transform,

representing DFT length.

y=fft(x,n);

In this case, fft pads the input sequence with zeros if it is shorter than n, or truncates

the sequence if it is longer than n. If n is not specified, it defaults to the length of the

input sequence.

2) The function axis is used to control axis scaling and appearance. Please turn to help

axis for more information.

3) The function roots(c) computes the roots of the polynomial whose coefficients are

the elements of the vector c. Please refer to help polyval to find out how to use the

function polyval.

4) Frequency Response (Analog Domain): freqs evaluates frequency response for an

analog filter by two input coefficient vectors b and a. Its operation is similar to that of

freqz; you can specify a number of frequency points to use (by default, the function

uses 200), supply a vector of arbitrary frequency points, and plot the magnitude and

Page 6: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

phase response of the filter.

5) The function clf is to used to clear current figure. Another function clear is to clear

variables and functions from memory. Don’t got confused by them.

6) figure(1); figure(2);…figure(n) can display a total of n pictures in n windows.

Requirements

1. DFT

Given njenx )9.0()( 6/ 0< = n < = 20,

20

0

)()(n

njj nxeeX , please

complete the following program DFT for given x(n). Please plot X( je )

magnitude and angle parts frequency outline.

Note:

(a) If we set x=[x(0) x(1) …x(k)...x(n)], k=0,1,...,n. It will separate a

number of (n+1) points in ],0[ duration as the interval of nk / .

(b) If },,1,0,100,{ MkneWkn

mj

, then X

j WeXX )( , where

)][exp( nkM

jW T

(c) The program is as following. Please complete it.

n=0:20; x=(0.9*exp(j*pi/6)).^n;

k=-200:200; w=(pi/100)*k;

X= ;

magX= ; angX= ;

figure(1);

subplot(2,1,1); plot(w/pi,magX); grid;

axis([-2,2,0,10]);

xlabel(‘frequency in units of pi’); ylabel(‘|X|’);

title(‘Magnitude Part’);

subplot(2,1,2); plot(w/pi,angX/pi); grid;

axis([-2,2,-.5,.5]);

xlabel(‘frequency in units of pi’); ylabel(‘radians/pi’);

title(‘Phase Part’);

2. FFT

Set sampling instants from 0 to 0.6s in steps of 1 ms. Generate a compound

sinusoidal sequence x of your own value. Please calculate x’s FFT by using fft(x)

or fft(x,n). Please plot the magnitude of the transformed sequence

Note:

(a) n should be power of two in order to perform FFT.

(b) Change the value of x and n, then try your program again.

Page 7: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

3. System’s roots

Given characteristic equation of a system

1) 010178 23 sss

2) 01872 23 sss

Please edit two programs to solve roots of the characteristic equation and record

the results.

Note:

(a) Using r=roots(n) to get the roots of characteristic equation. The “n” is

characteristic equation’s coefficient.

(b) Please analyze the two equations’ roots. What is their difference?

(c) Is the system stable? Why?

4. Sinusoidal solution of LTI system

Given a system described by the second-order differential equation:

)(6)(10)(

)(7

)(2

2

txtytd

tdy

dt

tyd

Please

(a) Analyze the system’s transfer function H(s).

(b) When x(t)=6cos(3t+50), Edit MATLAB program to get expression

of H(j3).

(c) When the system is excited by x(t)=6cos(3t+50), edit MATLAB

program to calculate the expression of the system’s zero state

response )(ty zs .

Note:

Please complete the following program.

n=[ ];

d=[ ];

h=polyval(n, )/polyval(d, );

ymag=6*abs(h);

yphase= ;

ymag

yphase

5. The impulse Response of a LTI system is

1

0 t

h(t)

1

Page 8: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

Please

1) Analyze the Laplace transform of h(t) directly.

2) If input function is u(t), use the h(t) you have got from (a) to analyze Y(s)

directly.

3) Edit MATLAB program to calculate y(t) from the Y(s) you have got

from (b).

Note:

(a) Use syms or sym to create the symbolic variable.

(b) Use ilaplace to get ILT results.

6. Analog system’s frequency response

An analog system’s transfer function is 14.0

16.05.0)(

2

2

ss

sssH . Please edit a

MATLAB program to plot its frequency response.

Note:

(a) Use w=logspace(-1,1) to generate a logarithmically spaced vector.

(b) You can call freqs without output arguments to plot both magnitude

versus frequency and phase versus frequency.

Page 9: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

INFE 5201 SIGNALS AND SYSTEMS

Assignment 3: Discrete-time LTI System and Filter Design

Name , Class&Student ID

Aim

1. To review Discrete Signal’s ZT, IZT, h(n), s(n),)( jeH

, etc.

2. To get discrete system’s zeros and poles, analyze the system’s stability.

3. To study difference equation number solution and program’s solution.

4. To design digital Butterworth filter and chebyshev filter.

Introduction

1) Transfer function: The transfer function is a basic z-domain representation of a

digital filter, expressing the filter as a ratio of two polynomials. It is the principal

discrete-time model for MATLAB Signal Processing Toolbox. The transfer function

model description for the z-transform of a digital filter’s difference equation is

)()1()2()1(

)1()2()1()(

1

1

zXznaazaa

znbbzbbzY

na

nb

Here, the constants b(i) and a(i) are the filter coefficients, and the order of the filter

is the maximum of na and nb. In MATLAB, you store these coefficients in two

vectors (row vectors by convention), one row vector for the numerator and one for

the denominator.

2) Zero-Pole Analysis: The zplane function plots poles and zeros of a linear system.

For a system in zero-pole form, supply column vector arguments z and p to zplane:

zplane(z,p). For a system in transfer function form, supply row vectors b and a as

arguments to zplane: zplane(b,a). Note that if b and a are both scalars they will be

interpreted as z and p.

3) Zero-Pole-Gain: The factored or zero-pole-gain form of a transfer function is

))(())2())(1((

))(())2())(1((

)(

)()(

npzpzpz

nqzqzqzk

zp

zqzH

By convention, MATLAB stores polynomial coefficients in row vectors and

polynomial roots in column vectors. In zero-pole-gain form, therefore, the zero

and pole locations for the numerator and denominator of a transfer function reside

in column vectors. The factored transfer function gain k is a MATLAB scalar.

The poly and roots functions convert between polynomial and zero-pole-gain

representations. For example, a simple IIR filter is

b=[2,3,4]; a=[1 3 3 1];

Page 10: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

The zeros and poles of this filter are

q=roots(b)

q=-0.7500+1.1990i

-0.7500+1.1990i

p=roots(a)

p=-1.0000

-1.0000+0.0000i

-1.0000-0.0000i

k=b(1)/a(1)

k=2

Returning to the original polynomials,

bb=k*poly(q)

bb= 2.0000 3.0000 4.0000

aa=poly(p)

aa= 1.0000 3.0000 3.0000 1.0000

Note that b and a in this case represent the transfer function

133

432

331

432)(

23

23

321

21

zzz

zzz

zzz

zzzH

For b=[2 3 4], the roots function misses the zero for z equal to 0. In fact, it misses

poles and zeros for z equal to 0 whenever the input transfer function has more

poles than zeros, or vice versa. This is acceptable in most cases. To circumvent the

problem, however, simply append zeros to make the vectors the same length

before using the roots function, for example, b=[b 0].

4) Partial Fraction Expansion (Residue Form): Each transfer function also has a

corresponding partial fraction expansion or residue form representation, given by

)(1

11)1()2()1(

)(1

)(

)1(1

)1(

)(

)( nmznmkzkkznp

nr

zp

r

za

zb

provided H(z) has no repeated poles. Here, n is the degree of the denominator

polynomial of the rational transfer function b(z)/a(z). If r is a pole of multiplicity

rs , then H(z) has terms of the form

rs

r

zjp

sjr

zjp

jr

zjp

jr

))(1(

)1(

))(1(

)1(

)(1

)()12)11

The residuez function in the Signal Processing Toolbox converts transfer functions

to and from the partial fraction expansion form. The “z” on the end of residuez

stands for z-domain, or discrete domain. residuez returns the poles in a column

vector p, the residues corresponding to the poles in a column vector r, and any

improper part of the original transfer function in a row vector k. resuduez

determines that two poles are the same if the magnitude of their difference is

smaller than 0.1 percent of either of the poles’ magnitudes.

Partial fraction expansion arises in signal processing as one method of finding the

Page 11: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

inverse z-transform of a transfer function. For example, the partial fraction

expansion of 21

1

861

84)(

zz

zzH is

b=[-4 8]; a=[1 6 8];

[r, p, k]=residuez(b,a)

r=-12

8

p=-4

-2

k=[]

corresponding to 11 21

8

41

12)(

zzzH .

5) Repeat Statement: The general format is

for varivble=expression

statement

statement

end

The columns of the expression are stored one at a time in the variable while the

following statements, up to the end, are executed. In practice, the expression is

almost always of the form scalar : scalar, in which case its columns are simply

scalars. The scope of the for statement is always terminated with a matching end.

Please use help for to see an example.

6) Frequency Response (Digital Domain): freqz uses an FFT-based algorithm to

calculate the z-transform frequency response of a digital filter. Specifically, the

statement [h,w]=freqz(b,a,n) returns the n-point complex frequency response,

)( jeH , of the digital filter.

)(

)(

)1()2()1(

)1()2()1()(

najj

nbjjj

enaaeaa

enbbebbeH

In its simplest form, freqz accepts the filter coefficient vectors b and a, and an

integer n to specifying the number of points at which to calculate the frequency

response. freqz returns the complex frequency response in vector h, and the actual

frequency points in vector w in radians/second. If you call freqz without output

arguments, it automatically plots both magnitude versus frequency and phase

versus frequency.

7) Symbolic variables: x = sym('x') creates the symbolic variable with name 'x' and

stores the result in x. Statements like pi = sym('pi') and delta = sym('1/10') create

symbolic numbers which avoid the floating point approximations inherent in the

values of pi and 1/10. The pi created in this way temporarily replaces the built-in

numeric function with the same name. syms is short-cut for constructing symbolic

objects. For example, syms arg1 arg2 ... is short-hand notation for

Page 12: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

arg1 = sym('arg1');

arg2 = sym('arg2'); ...

8) Filter Design: The Signal Processing Toolbox provides functions that support a

range of filter design methodologies, including Infinite Impulse Response (IIR) and

Finite Impulse Response (FIR) filter design problems. The toolbox provides five

different types of classical IIR filters, each optimal in some way. In this assignment,

you are required to try two types of them: Butterworth Filter and Chebyshev Filter.

Requirements

1. Inverse Z Transform (IZT)

Given )9.01()9.01(

1)(

121

zzzX , please edit a MATLAB program to get the

partial fraction expansion.

Note:

(c) Please use the command poly and residuez. If you need help, turn to help or

the introduction part on page 2 and page 3 of this report.

(d) In your report, write down the expression of X(z) you get by using poly.

(e) In your report, write down the expression of X(z) you get by using poly and

residuez. Then, analyze the expression of x[n] from X(z).

2. Stability of a discrete system

The transfer function of an LTI system is 48.096.15.2

9.06.12)(

23

2

zzz

zzzH . Please

edit MATLAB program to calculate the characteristic-equation roots.

Note:

(a) Use roots in your program.

(b) Is the system stable or unstable? Why?

3. Check the solution of LTI discrete system

Given y(0)=0, from difference equation y(n)-0.6y(n-1)=4u(n), we can get the solution

is )(]6.01[10)( nuny n . Please

(1) Calculate y(n) n=1,2,3,4 from the solution directly,. Write them down on your

report.

(2) edit MATLAB program to calculate y(n), and check them with the y(n) you have

got from (a).

Note:

(a) Please use for to realize the repeat statement in your program.

(b) When using for, can you set y(0)=0? Why?

Page 13: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

4. Digital system’s frequency response

A digital system’s transfer function is 21

21

4.01

3.02.0)(

zz

zzzH . Please edit a

MATLAB program to plot its frequency response.

Note:

Use freqz(b,a,n) to get digital system’s complex frequency response. 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. Please set

n=128 in your program.

5. Digital system’s analysis

Given a LTI system: y(n)=0.81y(n-2)+x(n)-x(n-2), please

(1) Analyze the expression of transfer function H(z) from the given difference

equation of this system.

(2) Edit MATLAB program to calculate its impulse response and step response.

(3) Edit MATLAB program to plot this system’s frequency response )( jeH .

(4) Please plot both the impulse response and step response in same figure.

Note:

(a) Use dimpulse to get the impulse response of discrete-time linear systems;

Use dstep to get the step response of discrete-time linear systems.

(b) You can call freqz without output arguments to plot both magnitude

versus frequency and phase versus frequency.

6. Butterworth digital filter design

Please design a 9 degree lowpass Butterworth digital filter. Its cutoff frequency is 300

Hz, and the sampling frequency is 1000 Hz.

Note:

(d) Use butter(n, 300/500) to design the filter. The second input argument to

butter indicate the cutoff frequency, normalized to half of the sampling

frequency (the Nyquist frequency).

(e) Use freqz(b,a,128,1000) to plot the filter’s frequency response. Please

explain each argument’s meaning in your report.

7. Lowpass Chebyshev type 1 filter design

The Chebyshev type 1 filter minimizes the absolute difference between the ideal and

actual frequency response over the entire passband by incorporating an equal ripple of

Rp dB in the passband. Stopband response is maximally flat. The transition from

passband to stopband is more rapid than for the Butterworth filter.

Please design a 9 degree lowpass Chebyshev type 1 filter. Its cutoff frequency is 300

Hz. Its ripple coefficient Rp=0.5. The sampling frequency is 1000 Hz.

Note:

a) Please use the command [b,a]=cheby1(n,Rp,Wn) to design a Chebyshev type

Page 14: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

1 filter. The meaning of the argument Wn is similar to that of Butterworth

filter design.

b) Use freqz(b,a,512,1000) to plot the filter’s frequency response.

8. (Optional)Bandpass Chebyshev type 1 filter design

Please design a 10 degree bandpass Chebyshev type 1 filter. Its ripple coefficient

Rp=0.5. Its pass band is 100Hz<w<200Hz. The sampling frequency is 1000 Hz.

Please plot the filter’s impulse response.

Note:

(a) Please use the command [b,a]=cheby1(n,Rp,Wn) to design a Chebyshev type

1 filter. To design a bandpass filter, Wn should be a two-element vector: Wn =

[W1 W2]. cheby1 returns an order 2n bandpass filter with passband W1 < W

< W2. Please note that Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to

half the sampling frequency.

(b) Use impz(b,a,m) to computes m samples of the impulse response. Set the

value of m by yourself.

Page 15: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

INFE 5201 SIGNALS AND SYSTEMS

Assignment 4: Continuous-time LTI system

Name , Class&Student ID

Aim

1. To study time-domain analysis of continuous-time LTI system.

2. To get the frequency response of a continuous-time system.

3. To get the continuous-time system’s zeros and poles, analyze the system’s stability.

Introduction

1) Transfer function model: A Continuous-time LTI system can be described by a linear constant

coefficient differential equation of the form

)()0()()1-()()()()0()()1-()()( )1()()1()( txbtxMbtxMbtyatyNatyNa MMNN

The system function )(sH can easily be computed

)0()1-()(

)0()1-()()(

1

1

asNasNa

bsMbsMbsH

NN

MM

In MATLAB, we store the constants )(ib and )(ia in two row vectors, one for the numerator

and one for the denominator. Then the tf function can be used to create transfer function model.

SYS = tf(NUM,DEN) creates a continuous-time transfer function SYS with numerator NUM and

denominator DEN.

2) Time response: The lsim function simulates the time response of continuous linear systems to

arbitrary inputs.

3) Impulse response: The impulse function plots the impulse response of a continuous-time

system.

4) Step response: The step function plots the step response of a continuous-time system.

5) Frequency response: The freqs function returns the frequency response of a continuous-time

system.

6) Zero-Pole analysis: The pzmap function creates a pole-zero plot of a continuous-time system.

7) Please use help to find out the description of the functions above.

Page 16: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

Requirements

1. There are four analogy filters described by the following differential equations. Please edit

MATLAB program to plot the impulse response and the step response for each system.

(1) )()()(2)( txtytyty

(2) )()()(2)( txtytyty

(3) )()()()( txtytyty

(4) )()()()()( txtxtytyty

2. Given a system described by the second order differential equation

)()(6)()( txtytyty

(1) Plot the system’s impulse response and step response using MATLAB.

(2) When the input signal is)()( tuetx t

, please calculate the zero-state response.

3. The system function of a third-order butterworth low-pass filter is given below

122

1)(

23

ssssH

Edit MATLAB program to plot this system’s frequency response.

4. Two causal continuous-time system’s system function are described as

(1)122

1)(

23

ssssH

(2)23332

1)(

2345

2

sssss

ssH

Create the pole-zero plot of the system, and determine whether it’s stable or not.

5. There are six continuous-time systems, and the poles of each system functions are given below.

Here we assume that no zero for every system.

(1) 0p (2) 2p

(3) 2p (4) jp 21 , jp 22

(5) jp 411 , jp 412 (6) jp 411 , jp 412

Create the pole-zero plots of the six systems above using MATLAB respectively. And plot the

impulse-response for every system. Based on the plots, analyze how the pole-zero’s position

impacts system’s impulse-response characteristics.

Page 17: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

6. We got three continuous-time systems, and their system functions are described as,

(1)172

1)(

2

sssH

(2)172

8)(

2

ss

ssH

(3)172

8)(

2

ss

ssH

The systems above have the same poles, but different zeros. Plot each system’s pole-zero plots and

impulse-response respectively using MATLAB. Based on the plots, analyze how the pole-zero’s

position impacts system’s impulse-response characteristics.

Page 18: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

INFE 5201 SIGNALS AND SYSTEMS

Assignment 5: Discrete-time LTI system

Name , Class&Student ID

Aim

1. To study time-domain analysis of discrete-time LTI system.

2. To get the frequency response of a discrete-time system.

3. To get the discrete-time system’s zeros and poles, analyze the system’s stability.

4. To compute the convolution between two finite-duration sequence.

Introduction

1) Transfer function model: A discrete-time LTI system can be described by a linear constant

coefficient difference equation of the form

)()()1()1()0()()()1()1()0( MnxMbnxbbNnyNanyaa

The system function )(sH can easily be computed

N

M

zNazaa

zMbzbbsH

)()1()0(

)()1()0()(

1

1

In MATLAB, we store the constants )(ib and )(ia in two row vectors, one for the numerator

and one for the denominator.

2) Time response: The filter function compute the output signal of discrete-time systems to an

input signal and is invoked by

y = filter(b,a,X)

Here, vector X is the input signal, and the vector b and a is respectively numerator coefficient and

denominator coefficient.

3) Impulse response: The impz function plots the impulse response of a discrete -time system and

is invoked by impz(b,a).

4) Convolution: The conv function compute the convolution between two finite-duration

sequence.

5) Frequency response: The freqz function returns the frequency response of a discrete-time

system.

Page 19: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

6) Zero-Pole analysis: The pzmap function plots poles and zeros of a discrete-time system.

7) Please use help to find out the description of the functions above.

Requirements

1. Given the difference equations of discrete-time systems as follows. Plot the system’s impulse

response respectively.

(1) )()2(2)1(3)( nxnynyny

(2) )1(3)()2(8.0)1(5.0)( nxnxnynyny

2. Given the difference equations of the system as follow,

)()2(25.0)1()( nxnynyny

Please Plot the impulse response and the step response of this system using MATLAB.

3. Please edit MATLAB program to calculate the convolution between the following two

sequences.

}1 1, ,2 ,1{)(1

nx

0

22- 1)(2

其他

nnx

4. Given a discrete-time system as follow

)2(0317.0)1(0441.0)3(3679.0)2(4641.1)1(0204.2)( nxnxnynynyny

Plot the system’s frequency response using MATLAB.

5. Given the system functions of the causal discrete-time systems as follows,

(1)3.0005.05.0

12)(

23

2

zzz

zzzH

(2)1333

2)(

234

23

zzzz

zzzH

Create the Zero-Pole plots for each system and determine if the system is stable.

6. Given the zeros and poles of six discrete-time systems as follows,

(1) 0z , 25.0p

(2) 0z , 1p

(3) 0z , 25.1p

Page 20: INFE 5201 SIGNALS AND SYSTEMSisip.bit.edu.cn/docs/2017-10/20171007124923012276.pdf · 2017-10-07 · INFE 5201 SIGNALS AND SYSTEMS Assignment 1: Introduction to MATLAB Name, Class&Student

(4) 0z , 61 8.0

j

ep , 62 8.0

j

ep

(5) 0z , 81

j

ep , 82

j

ep

(6) 0z , 4

3

1 2.1

j

ep , 4

3

2 2.1

j

ep

Create the pole-zero plots of the six systems above using MATLAB respectively. And plot the

impulse-response for every system. Based on the plots, analyze how the pole-zero’s position

impacts system’s impulse-response characteristics.

7. Given the system functions of the discrete-time systems as follows,

(1)

)8.0)(8.0(

)2()(

66

jj

ezez

zzzH

(2)

)8.0)(8.0(

)2()(

66

jj

ezez

zzzH

The systems above have the same poles, but different zeros. Plot each system’s pole-zero plots and

impulse-response respectively using MATLAB. Based on the plots, analyze how the position of

zeros of the system influence the characteristic of the impulse-response.