Chapter 3 Solution of State Space Models Using Matlab PDF

Title Chapter 3 Solution of State Space Models Using Matlab
Course Linear Controller Design & State Space with Matlab Applications
Institution Newcastle University
Pages 26
File Size 979.4 KB
File Type PDF
Total Downloads 95
Total Views 147

Summary

Solution of State Space Models Using Matlab...


Description

Chapter 3

EEE8013

Chapter #3

EEE8013 Linear Controller Design and State Space Analysis Solution of State Space Models Using Matlab

1. Solution using Eigenvalues and Eigenvectors ............ 2 2. Solution using State Transistion Matrix ................... 18

Module Leader: Dr Damian Giaouris – [email protected]

1/26

Chapter 3

EEE8013

1. Solution using Eigenvalues and Eigenvectors 1.1 Case 1: Real and unequal eigenvalues Example: 3.1  x   2 2   x1  Assume that  1       x2   2  5  x2 

To find the eigenvalues using the analytical method:

I  A 0 

 2 2

2  0  2  7   6  0 5 

To find the eigenvalues we need to solve the characteristic equation: 2  7   6  0    6,1 .

Using Matlab we can use the command eig(A) >> A=[-2 2;2 -5]; >> eig(A) ans = -6 -1

Module Leader: Dr Damian Giaouris – [email protected]

2/26

Chapter 3

EEE8013

To find the eigenvalues and the corresponding eigenvectors we use the Matlab command [e,v]=eig(A). >>

A=[-2 2;2 -5];

>> [e,v]=eig(A)  0.4472 v1     0.8944 

e=

 0.8944 v2     0.4472

-0.4472 -0.8944 0.8944 -0.4472 v=

1  6

-6

0

2  1

0 -1 Thus we should say that the general solution of the state space system x

 2 2

2  x can be written as: 5 

6 x  C1  v1  e  t  C2  v2  e t

 0.4472  6 t   0. 8944  t  x  t   C1  e C 2    0. 4472 e  0.8944   

To find the particular solution we can use the initial conditions to find C1 and C2. 1  Assume: x 0     . 0  Module Leader: Dr Damian Giaouris – [email protected]

3/26

Chapter 3

EEE8013

 0. 4472   0. 8944  1   C2  x 0   C1       0. 8944  0. 4472  0   0.4472 C1  0. 8944C2   1    0  0 8944 0 4472  . C . C   1 2    0.4472   0 .8944

e

x(0 ) 1

0. 8944 C1  1  C1   0. 4472  0. 8944 1           0.4472  C2  0  C2   0.8944 0. 4472  0 

>> C=inv(e)*[1 0]' C1

C = C2 -0.4472 -0.8944

The particular solution is:  0.4472   6 t  0. 8944  t x t    0.4472  e  0. 8944   e 0 8944 0 4472  . .     We can now simulate the state space system and the analytical solution using eigenvectors.

Module Leader: Dr Damian Giaouris – [email protected]

4/26

Chapter 3

EEE8013

(Simulink File ex 1) State Space Check t he ICs 1 s Int egrat or2

Scope1

K*uve A

Analytical Solution Gain3 Gain1

Gain2 t

-6

Clock

e

u

exp(-6t ) [-0.4472;0.8944]

-0.4472

Mat h Funct ion Gain6 Gain4 -1

Scope2 Gain5

exp(-t ) e

u

[-0.8944;-0.4472]

-0.8944

Mat h Funct ion1

To obtain the state response of the system double click on either Scope 1 or Scope 2.

State response

Module Leader: Dr Damian Giaouris – [email protected]

5/26

Chapter 3

EEE8013

Example [Simulink file ex 2] A system is given by x  7 x  6 x  0, x0  1, x0  0 a) Find the particular solution You can solve this part as in chapter 1. The general solution is x  C1e t  C2e6 t . Using the initial conditions: => C1=6/5, C2=-1/5 and the particular solution is: x  65 et  15 e 6t Note: since r1 and r2 are negative the response is stable and it converges exponentially to zero (homogeneous system) without oscillations. (b)

Numerical Solution 7 Check ICs

Gain5 1 s

1 s

Integrator3

Integrator2

0

Scope

Constant 6 Gain1

Analytical solution Gain3

Gain2 t

-6

Clock

e

u

exp(-5t)

-1/5

Math Function Scope2 Gain4 -1

Gain6 e

u

exp(-t) 6/5

Math Function1

Module Leader: Dr Damian Giaouris – [email protected]

6/26

Chapter 3

EEE8013

The response of x(t) (c)Transform the system to state space form if y=x(t) You can solve this part as in chapter 2. By defining x1  x , x2  x 1  x1  x1   0      x2   6  7  x2 

y  x1  y  1 0  x

(d) State space X'

1 s

X

C K*u

Integrator1

Scope1

K*u A Scope3

Module Leader: Dr Damian Giaouris – [email protected]

7/26

Chapter 3

EEE8013

State response using state space representation

(e) Find the eigenvalues. Is the system stable? What will be the response type? >> clear all >> A=[0 1;-6 -7]; >> eig(A) ans = -1 -6 The eigenvalues of the system are: -1, -6 hence the system is stable with overdamped response.

To find the eigenvectors >> [e,v]=eig(A) e =

Module Leader: Dr Damian Giaouris – [email protected]

8/26

Chapter 3

EEE8013

0.7071

-0.1644

-0.7071

0.9864

v = -1

0

0

-6

(f) Find the general solution using the eigenvalues and eigenvectors  0.7071   t   0. 1644 6 t x t   C1  e  C2   e  . . 0 7071 0 9864    

To find the particular solution. (Compare your answer with i.)  0.7071  0. 1644  1  x 0   C1   C2       0. 7071   0. 9864  0   0 .7071   0.7071

1

0 .1644  C1  1  C1   0. 7071 0. 1644 1             0. 9864   C2  0  C2   0. 7071 0. 9864   0 

>> C=inv(e)*[1 0]'

C = 1.6971 1.2166 Module Leader: Dr Damian Giaouris – [email protected]

9/26

Chapter 3

EEE8013

The particular solution is:  0.7071   t 0. 1644  6 t x t   1.6971  e  1. 2166   e  0 .7071  0.9864 

You can now simulate this solution.

Numerical Solution 7 Check ICs

Ga in5 1 s

1 s

Integrato r3

Integrato r2

Sco pe

0 Consta nt 6 Ga in1

Analytical solution Ga in3

Ga in2 -6

t

e

Clock

exp(-5t)

u

-1/5

Mat h Function Sco pe2 Ga in4

Ga in6 e

-1

exp(-t)

u

6/5

Mat h Function1

State space X'

1 s

C

X

K*u

Integrato r1

Sco pe1

K*u A Sco pe3

Analytical Solution using eigenvectors

Ga in9 Ga in7

Ga in8 t

-1

Clock1

e

u

exp(-6t) [0.7071;-0.7071]

1.6971

Mat h Function2 Ga in12

Sco pe4 Ga in11

Ga in10 -6

e

u

exp(-t) [-0.1644;0.9864]

1.2166

Mat h Function3

Module Leader: Dr Damian Giaouris – [email protected]

10/26

Chapter 3

EEE8013

In the lecture notes we found a solution for the same problem using 1  1  eigenvectors as x  t   6 / 5   e t  1 / 5   e 6 t . Simulate this solution  1   6 

and check that it gives the same response as other solutions.

Tutorial problem 3: (ex 3 simulink file)  x1  2 1 5  x1  A homogeneous system is given by x 2   7 3 6 x 2  x 3  1 5 2  x3 

(a) Use Matlab to find the system eigenvalues and eigenvectors. Is the system stable? Justify your answer. >> A=[2 1 5;7 3 6;1 5 2]; v3

v2

>> [e,v]=eig(A)

v1

e = 0.3893

-0.4221 - 0.4075i

-0.4221 + 0.4075i

0.7716

-0.3641 + 0.4002i

-0.3641 - 0.4002i

0.5031

0.6025

0.6025

10.4432

0

0

v =

0 0

-1.7216 + 2.6447i 0

0 -1.7216 - 2.6447i

Module Leader: Dr Damian Giaouris – [email protected]

11/26

Chapter 3

EEE8013

Since one eigenvalue is 10.4432 (positive real) the system is unstable. 1  (b) Simulate the system in sate space form using x 0   0  and plot the state 0 

response for t  0 1. State Space Check the ICs 1 s Integrator2

Scope1

K*uve A

State response Tutorial problem 4: (ex 4 simulink file)

Module Leader: Dr Damian Giaouris – [email protected]

12/26

Chapter 3

EEE8013

x 1   2 A homogeneous system is given by x 2    7 x 3   1

1 1  x1  3 2  x2  5 0  x3 

(a) Use Matlab to find the system eigenvalues and eigenvectors. Is the system stable? Justify your answer. >> A=[2 -1 1;-7 3 2;-1 5 0]; >> [e,v]=eig(A) e = -0.0000

0.2171

-0.2604

0.7071

0.5524

-0.5527

0.7071

0.8048

0.7916

5.0000

0

0

0

3.1623

0

0

0

-3.1623

v =

The system is unstable with overdamped response. (b) Write down the general solution using the previously found eigenvectors?

Module Leader: Dr Damian Giaouris – [email protected]

13/26

Chapter 3

EEE8013

 0 x t   C1  0.7071  0.7071

 e5 t  C 2  

0 .2171  0 .5524 e3.1623 t  C 3   0 .8048 

 0.2604  0 .5527 e3 .1623 t    0 .7916 

1  (c) For x0  1  find the particular solution then simulate both state space 0 

form and particular solution and plot the state response for t 0 1.5 . Could we still use inv(e)*X(0) to find the 3 constants?? State Space Check the ICs 1 s Integrat or2

Scope1

K*uve

Scope3

A

Analytical Solution Gain3 Gain2 t

eu

5

Clock

Gain1

exp(-6t) [0 0.7071 0.7071]'

-1.9799

Mat h Function Gain6 Gain4 -K-

eu

Scope2 Gain5

exp(-t) -K-

3.0309

Mat h Function1

Gain9 Gain7 -K-

eu

Gain8

exp(-t) -K-

-1.3128

Mat h Function2

Module Leader: Dr Damian Giaouris – [email protected]

14/26

Chapter 3

EEE8013

State response

1.2 Case 2: Repeated Eigenvalues x  1  1 x 

1 A homogeneous system is given by  1       x2  1 3  x2 

Analytically find the Eigen values, Eigenvectors and general solution.  1 1  1 A   1, 2  2  v1, 2    1 3   1

In that case I have that  I  A  b  0 (b is called the generalised eigenvector 2

of A), which can be written as  I  A I  A b 0 . Now I substitute v   I  A b and I have  I  A v 0 , i.e. v is one eigenvector of A for the

eigenvalue  . Now it can be proved that the general solution of this system can be written as: x t   C1 vt  b e t  C2ve t .

Module Leader: Dr Damian Giaouris – [email protected]

15/26

Chapter 3

EEE8013

So in that case 1  v   I  A b      2 I  A b  1  1   b1  1  1  1   b1  b2   b1  0             1  1 1  b 1   b  b     2     1 2  b2  1 

 1  0   1 Hence the solution is: x t   C1    t    e2 t  C2   e2 t  1    1 1  

If we are given the initial conditions [1 0]T:  0   C2   1 C  1     2 x 0       C1   C2  0  C1  1

Now simulate both state space form and particular solution (analytical) and plot the state response for t  0 1.5 . x   3

18 x 

1 Exercise: Repeat the previous example for the system  1       x2   2  9  x2 

1.3 Case 3: Complex Eigenvalues

If I have complex eigenvalues then 1   2 and the corresponding eigenvectors are v1  v 2 . In that case the general solution is given by:

t  t x t   A1v1 e 1  A2 v2 e 2

Module Leader: Dr Damian Giaouris – [email protected]

16/26

Chapter 3

EEE8013

Exercise: Find the numerical and analytical solution of a homogeneous system (u=0) 1 / 2 with a state matrix: A    1

 1  , assuming  x 0    0 1 / 2    1

2. Solution using State Transition Matrix This is a general approach to solve state space models. As described in Chapter 1 for a scalar homogeneous DE: x  ax xt   e

at

the solution was

x 0 (no special cases) so can we do the same with x

, i.e.

x  eAt x0  ?

The solution of the homogeneous system can then be written as:

x(t)   t  x(0)  eAt x 0  The solution of the non-homogeneous system can be written as: t

x t     t  x 0      t    Bud 0

Where the first term is the response to initial conditions and the second term is the response due to external input u(t). In Matlab we use the command expm (not exp!!) to calculate

e At

Example:

Module Leader: Dr Damian Giaouris – [email protected]

17/26

Chapter 3

EEE8013

2   x1  2 , A     5   x2  2

x For the system  x

2  assuming that x(0)=[1  5

2] what is the value of x(5)? >> clear all >> A=[-2 2;2 -5]; >> X_5=expm(A*5)*[1 2]' X_5 = 0.0108 0.0054 Example: (Simulink file ex 2) 1  x1  x1   0  For the system described in Tutorial problem 2 x2    6  7  x2 

Find

the

solution

using

state

transition

matrix

method

x(t)  e At x 0     t  x(0)

Analytical Solution using state transition matrix Matrix Mul ti pl y Product3 [2x2] A1

Scope6

expm Product2 Matrix Exponenti al 1

Clock3 [1 0]' Ini ti al condi ti ons

Module Leader: Dr Damian Giaouris – [email protected]

18/26

Chapter 3

Expm:

EEE8013

DSP

system

toolbox/Math

functions/Matrices

and

linear

algebra/Matrix operations

Check that you get the same answer as in ex 2!

Tutorial problem 5: (ex 5 simulink file) 1  x 1  x1   0     For the following system x2   2  3 x 2 

a) Simulate the state space system and plot the state response. x1(0)=1, x2(0)=0. b) Find the state response using the state transition matrix method.

Module Leader: Dr Damian Giaouris – [email protected]

19/26

Chapter 3

EEE8013 State space X'

X

1 s Integrator1

Scope1

K*u A

Analytical solution using state transtion matrix Matrix Mul tiply Product3 [2x2] A1

Scope6

expm Product2 Matrix Exponential1

Clock3 [1 0]' Initial conditions

State response Now try to find the same solution using eigenvalues and eigenvectors and crosscheck your answer?

Module Leader: Dr Damian Giaouris – [email protected]

20/26

Chapter 3

EEE8013

c) Find the state response for a unit step input assuming same initial 0  conditions and B    using state space representation and using 1  t

 x t  e At x 0   e A t  Bud  . Show each component of the response 0

(i.e. the part that depends on the initial conditions and the part that depends on the input signal).

State space I B 1

X'

K*u

U

X

1 s Integrat or2

Scope2

K*u A2

Matrix Mult ipl Product 4 [2x2] Constant1

expm Product 1 Scope5

Matrix Exponential 2 Clock2 [1 0]' Constant2

Scope4 Matrix Mult ipl Product 7 Scope3 -C-A

expm Product 5 Matrix Exponential 3

Matrix Mult ipl

1 s

Product 6 Integrat or5

Clock4 -CBU

Module Leader: Dr Damian Giaouris – [email protected]

21/26

Chapter 3

EEE8013

Response to initial conditions

Response to external input u(t)

Overall response Module Leader: Dr Damian Giaouris – [email protected]

22/26

Chapter 3

EEE8013

Tutorial problem 6: (ex 6 simulink file) Find the output response y(t) of the state space system described by: x 1   1  0.5 x1  0.5 x1    u , y  1 0  x    1    0  x2  0   2  x2 

Where u(t) is unit step and the system initial conditions are [1 0]T. Simulate the state space form and the solution using state transition matrix. This is a non-homogeneous system with non-zero initial conditions.

Overall response

Module Leader: Dr Damian Giaouris – [email protected]

23/26

Chapter 3

EEE8013

Linear Controller Design and State Space Analysis EEE8013 Tutorial Exercise III

1. A system is given by x

 2 2

2  x 5 

(a) Use Matlab to find the eigenvalues and eigenvectors of this system. (b) Find the general solution using the previously found eigenvectors.

1  0 

(c) Find the particular solution if x 0     . (d) Simulate the particular solution obtained in (c) and Crosscheck you answer by simulating the system in state space form. (e) Plot the state response of the system.

2. A system is given by x  7 x  6 x  0, x0  1, x0  0 (a) Find the particular solution of the differential equation. (b) Simulate both numerical and analytical solution obtained in (a) and plot the response x(t). (c) Transform the system to state space form if y = x(t). (d) Simulate the state space form and plot the state response. (e) Using Matlab find the eigenvalues and eigenvectors of the system. What is the response type? (f) Find the general solution using the eigenvectors then find the particular solution using the given initial conditions. (g) Simulate the particular solution obtained in (f) and crosscheck your answer. M...


Similar Free PDFs