+ All Categories
Home > Documents > ECE 4115 Control Systems Lab 1 Spring 2005 Chapter 2 Time Response of Systems Prepared by: Nisarg...

ECE 4115 Control Systems Lab 1 Spring 2005 Chapter 2 Time Response of Systems Prepared by: Nisarg...

Date post: 02-Jan-2016
Category:
Upload: justina-skinner
View: 213 times
Download: 0 times
Share this document with a friend
Popular Tags:
36
ECE 4115 Control Systems Lab 1 Spring 2005 Chapter 2 Time Response of Systems Prepared by: Nisarg Mehta
Transcript

ECE 4115Control Systems Lab 1

Spring 2005

Chapter 2Time Response of SystemsPrepared by: Nisarg Mehta

Matlab

Start Run \\laser\apps Open MatlabR14 and double click

on MATLAB 7.0.1

Previous Class 4 basic types of LTI models

Transfer Function: tf, tfdata Zero-pole-gain model: zpk, zpkdata State-Space models: ss, ssdata Frequency response data: frd

Conversion between models Model dynamics: pzmap, pole, eig,

zero, dcgain

TIME RESPONSE OF TIME RESPONSE OF SYSTEMSSYSTEMS

Once a model of a system has Once a model of a system has been defined, we might be been defined, we might be interested in knowing the time interested in knowing the time response of such system to a response of such system to a certain input. certain input.

The Control Systems Toolbox of The Control Systems Toolbox of MATLAB provides several MATLAB provides several commands to perform this task.commands to perform this task.

Objectives

Impulse Response (impulse) Step Response (step) General Time Response (lsim) Polynomial multiplication (conv) Polynomial division (deconv) Partial Fraction Expansion (residue)

The impulse response of a system is its output when the input is a unit impulse.

Impulse Response

Impulse ResponseComman

dHelp

impulse Impulse response of LTI models.

impulse(sys) plots the impulse response of the LTI model sys (created with either tf, zpk, or ss). The time range and number of points are chosen automatically.

impulse(sys,tfinal) simulates the impulse response from t=0 to the final time t=tfinal.

impulse(sys,t) uses the user-supplied time vector t for simulation.

Impulse Response

Command

Help

impulse

(cont’d)

When invoked with left-hand arguments, [y,t]=impulse(sys) returns the output response y and the time vector t used for simulation. No plot is drawn on the screen. For state-space models, [y,t,x]=impulse(sys,...) also returns the state trajectory x.

Step Response

The step response of a system is its output when the input is a unit step.

Step Response

Command

Help

step Step response of LTI models.

step(sys) plots the step response of the LTI model sys (created with either tf, zpk, or ss). The time range and number of points are chosen automatically.

step(sys,tfinal) simulates the step response from t=0 to the final time t=tfinal.

step(sys,t) uses the user-supplied time vector t for simulation.

Step Response

Command

Help

step

(cont’d)

When invoked with left-hand arguments, [y,t]=step(sys) returns the output response y and the time vector t used for simulation. No plot is drawn on the screen. For state-space models, [y,t,x]=step(sys,...) also returns the state trajectory x.

Problem 1: Problem 1: Given the LTI systemGiven the LTI system

Plot the following responses forPlot the following responses for

a) The impulse response using the a) The impulse response using the impulseimpulse command. command.

b) The step response using the b) The step response using the stepstep command. command.

c) The response to the input calculated c) The response to the input calculated using both the using both the lsimlsim and the and the residueresidue commands commands

Problem 1

1s5s4s2

2s3)s(G

23

)t5.0sin()t(u

H:\ECE4115\Chp2\Chp2_1.m

clear allclear all

close allclose all

clcclc

A=[3 2];A=[3 2];

B=[2 4 5 1];B=[2 4 5 1];

sys=tf(A,B);sys=tf(A,B);

t=0:0.01:10;t=0:0.01:10;

impulse(sys,t);impulse(sys,t); %Impulse Response%Impulse Response

figure;figure;

Step(sys,t);Step(sys,t); %Step Response%Step Response

Response to a general input

The general response of a system to any input can be computed using the lsim command.

Response to a general input

Command Help

lsim Simulate time response of LTI models to arbitrary inputs. lsim(sys,u,t) plots the time response of the LTI model sys to the input signal described by u and t. The time vector t consists of regularly spaced time samples and u is a vector whose i-th entry specifies the input value at time t(i). lsim(sys,u,t,x0) specifies the initial state vector x0 at time t(1) (for state-space models only); x0 is set to zero when omitted.

Response to a general input

Command

Help

lsim

(cont’d)

y=lsim(sys,u,t) returns the output history Y. No plot is drawn on the screen. For state-space models, [y,t,x]=lsim(sys,u,t,x0) also returns the state trajectory x, a matrix with as many columns as states.

Problem 1: Problem 1: Given the LTI systemGiven the LTI system

Plot the following responses forPlot the following responses for

a) The impulse response using the a) The impulse response using the impulseimpulse command. command.

b) The step response using the b) The step response using the stepstep command. command.

c) The response to the input calculated c) The response to the input calculated using both the using both the lsimlsim and the and the residueresidue commands commands

Problem 1

1s5s4s2

2s3)s(G

23

)t5.0sin()t(u

H:\ECE4115\Chp2\Chp2_1.m

clear allclear all

close allclose all

clcclc

A=[3 2];A=[3 2];

B=[2 4 5 1];B=[2 4 5 1];

sys=tf(A,B);sys=tf(A,B);

t=0:0.01:10;t=0:0.01:10;

%Impulse response%Impulse response

impulse(sys,t);impulse(sys,t);

H:\ECE4115\Chp2\Chp2_1.m

%Step response%Step response

figurefigure

step(sys,t);step(sys,t);

%Response to a sinusoidal input%Response to a sinusoidal input

u=sin(0.5*t);u=sin(0.5*t);

figurefigure

lsim(sys,u,t);lsim(sys,u,t);

Commands Commands convconv and and deconvdeconv

conv Convolution and polynomial multiplication. 

C=conv(A,B) convolves vectors A and B. If A and B are vectors of polynomial coefficients, convolving them is equivalent to multiplying the two polynomials.

deconv Deconvolution and polynomial division. 

[Q,R]=deconv(B,A) deconvolves vector A out of vector B. 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, such that B=conv(A,Q)+R

Polynomial MultiplicationPolynomial Multiplication

3s13s11s2s23s4s21s3s 23422

The polynomial product:The polynomial product:

can be solved in MATLAB by typing can be solved in MATLAB by typing

C=conv([1 3 -1],[2 -4 3])C=conv([1 3 -1],[2 -4 3])

and the following output will be obtainedand the following output will be obtained

C =C =

2 2 -11 13 -32 2 -11 13 -3

Polynomial DivisionPolynomial Division The polynomial division:The polynomial division:

can be computed in MATLAB by entering can be computed in MATLAB by entering [Q,R]=deconv([1 6 11 6],[1 2])[Q,R]=deconv([1 6 11 6],[1 2]) and the output is and the output is

  

Q =Q =  

1 4 31 4 3  

R =R =  

0 0 0 00 0 0 0

3 26 11 6

2

s s s

s

Command ResidueCommand Residue

Command

Help

residue Partial-fraction expansion (residues). 

[r,p,k]=residue(A,B) finds the residues, poles and direct term of a partial fraction expansion of the ratio of two polynomials B(s)/A(s).

Command ResidueCommand Residue

residue

(cont’d)

If there are no multiple roots

Vectors B and A specify the coefficients of the numerator and denominator polynomials in descending powers of s. The residues are returned in the column vector r, the pole locations in column vector p, and the direct terms in row vector k. 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.

)s(K)n(Ps)n(R

)2(Ps)2(R

)1(Ps)1(R

)s(A)s(B

Command ResidueCommand Residue

residue

(cont’d)

If P(j)= ... =P(j+m-1) is a pole of multiplicity m, then the expansion includes terms of the form

[b,a]=residue(r,p,k), with 3 input arguments and 2 output arguments, converts the partial fraction expansion back to the polynomials with coefficients in b and a.

m2 )j(Ps

)1mj(R

)j(Ps

)1j(R)j(Ps)j(R

Problem 2

Problem 2: Problem 2: Given the LTI systemGiven the LTI system

Find the step response using the Find the step response using the residueresidue command. Plot such response for command. Plot such response for

4s8s5s

2s3)s(G

23

Problem 2: Solution

)s(YL)t(y 1

s1

)s(U

s1

4s8s5s

2s3)s(U)s(G)s(Y

23

Recall thatRecall that

To determine the Inverse Laplace Transform of a rational To determine the Inverse Laplace Transform of a rational function, a partial fraction expansion is performed first, function, a partial fraction expansion is performed first, then each fraction is inverted and the individual inverse then each fraction is inverted and the individual inverse transforms are added up.transforms are added up.

H:\ECE4115\Chp2\Chp2_2.m

clear allclear all

close allclose all

clcclc

A=[3 2];A=[3 2];

B=[1 5 8 4];B=[1 5 8 4];

Bu=conv(B,[1 0]);Bu=conv(B,[1 0]);

[r,p,k]=residue(A,Bu)[r,p,k]=residue(A,Bu)

Chp2_2.m: Solution

r =r =

-1.50000000000000-1.50000000000000

-2.00000000000000-2.00000000000000

1.000000000000001.00000000000000

0.500000000000000.50000000000000

  

p =p =

-2.00000000000000-2.00000000000000

-2.00000000000000-2.00000000000000

-1.00000000000000-1.00000000000000

00

  

k =k =

[][]

After the partial fraction expansion has been After the partial fraction expansion has been determined, it can be seen that:determined, it can be seen that:

– Y(s)Y(s) has four poles, stored in vector has four poles, stored in vector p.p.– One of them is a repeated poleOne of them is a repeated pole

Then, Then, y(t)y(t) is given by: is given by:

t)3(pt)2(pt)1(pt)1(p e)4(re)3(rte)2(re)1(r)t(y

Problem 3

H:\ECE4115\Chp2\Chp2_3.m

clear allclear allclose allclose allclcclcA=[3 2];A=[3 2];B=[1 5 8 4];B=[1 5 8 4];sys=tf(A,B);sys=tf(A,B);

t=0:0.01:10;t=0:0.01:10;

%Step response%Step response[ystep,t]=step(sys,t);[ystep,t]=step(sys,t);

H:\ECE4115\Chp2\Chp2_3.m%Step response via the Inverse Laplace Transform%Step response via the Inverse Laplace Transform

Bu = conv(B,[1,0]);Bu = conv(B,[1,0]);[r,p] = residue(A,Bu);[r,p] = residue(A,Bu);ystep_res=r(1)*exp(p(1)*t)+r(2)*t.*exp(p(2)*t)ystep_res=r(1)*exp(p(1)*t)+r(2)*t.*exp(p(2)*t)+r(3)*exp(p(3)*t)+r(4)*exp(p(4)*t);+r(3)*exp(p(3)*t)+r(4)*exp(p(4)*t);

%Figures%Figures

subplot(2,1,1),plot(t,ystep_res,'k')subplot(2,1,1),plot(t,ystep_res,'k')xlabel('t')xlabel('t')ylabel('y')ylabel('y')subplot(2,1,2),plot(t,ystep,'k:')subplot(2,1,2),plot(t,ystep,'k:')xlabel('t')xlabel('t')ylabel('y')ylabel('y')

FiguresFiguresThe following Figure shows the step response using The following Figure shows the step response using the Inverse Laplace Transform (a) and the step the Inverse Laplace Transform (a) and the step command (b)command (b)

SummarySummary

Impulse response: Impulse response: ImpulseImpulse Step response: Step response: StepStep General time response: General time response: lsimlsim Polynomial multiplication: Polynomial multiplication: convconv Polynomial division: Polynomial division: deconvdeconv Partial fraction expansion: Partial fraction expansion: residueresidue

Homework #2Homework #2

H:\ECE4115\Chp2\HW2_1.mH:\ECE4115\Chp2\HW2_1.m H:\ECE4115\Chp2\HW2_2.m H:\ECE4115\Chp2\HW2_2.m H:\ECE4115\Chp2\HW2_3.mH:\ECE4115\Chp2\HW2_3.m

Questions???

Next Class: March 25th,2005


Recommended