Homework6 Sol Sebastian

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

T HE U NIVERSITY OF T EXAS AT S AN A NTONIO HOMEWORK # 6

EE 5143 Sebastian A. Nugroho


L INEAR S YSTEMS AND C ONTROL November 10, 2017

Due date of the homework is: Wednesday, November 8th @ 11:59pm.

1. Prove that the system represented in the controllable canonical form is always controllable.
Answer: The transfer function
b1 sn−1 + b2 sn−2 + . . . + bn
G (s) =
s n + a 1 s n −1 + a 2 s n −2 + . . . + a n
has the controllable canonical form with matrices A and B as
   
0 1 0 0 ... 0 0
 0 0 1 0 ... 0  0
   
 .. . . . ..  ,
A= . .. .. .. . .. B =  ...  .
 
 .    
 0 0 0 0 ... 1  0
− a n − a n −1 − a n −2 − a n −3 . . . − a 1 1

Forming the controllability matrix, we have

Co = B AB A2 B A3 B A4 B . . . An−1 B
 
 
0 0 0 0 0 ... 1
0 0 0 0 0 ... − a1 
2
 
0 0 0 0 0 . . . a1 − a2 
=  ... .. .. .. .. .. 
 
 .. .
 . . . . . . 
0 0 1 − a a 2−a . . . ∗
1 2

 1 
0 1 − a1 a21 − a2 ∗ ... ∗ 
1 − a1 a21 − a2 ∗ ∗ ... ∗

where 0 ∗0 indicates the non-zero value. Since the controllability matrix of this form will always
have the dimension of n × n, thanks to the unique structure of Co where ones appear on the anti-
diagonal elements, then Rank(Co ) = n, which finally implies that the controllable canonical form
is always controllable. 
2. Show that the controller design
> (t
h i
u(t) = − B> e A f −t) W −1 (t f ) e At f x0 − xt f

steers the system from x (t0 ) = x0 to x (t f ) = xt f .


Answer: The solution of any CT-LTI with nonzero input is
Z t
x (t) = e At x (0) + e A(t−τ ) Bu(τ ) dτ.
0

Suppose the system starts from x (0) = x0 and we want to achieve xt f at t = t f . Hence, we want
to prove that x (t f ) = xt f . With the aforementioned control input, then
Z t
f
x (t f ) = e At f x0 + e A(t f −τ ) Bu(τ ) dτ
0
Z t
f > (t
h i
= e At f x0 + e A(t f −τ ) B(− B> e A f −τ ) W −1 (t f ) e At f x0 − xt f ) dτ
0
Z t
f > (t
h i
= e At f x0 − e A(t f −τ ) BB> e A f −τ ) dτ (W −1 (t f ) e At f x0 − xt f )
0

1
h i
= e At f x0 − W (t f )(W −1 (t f ) e At f x0 − xt f )
h i
= e At f x0 − e At f x0 − xt f
= e At f x0 − e At f x0 + xt f
= xt f .

3. You are given the following CT LTI system:
   
0 1 1 1 1 0
1 0 0 0 0 0
ẋ (t) = 
1 1 0
 x (t) +   u ( t ).
0 0 1
1 1 1 0 0 1
We wish to find a state feedback controller u = Kx (not u = −Kx) such that Acl = A + BK is block
diagonal with eigenvalues λ1,2 = {2, 3} assigned to the first diagonal block, and eigenvalues
λ3,4 = {0, 1} assigned
 to second diagonal block. Note that your K matrix can be written as:
k1 k2 k3 k4
K= .
k5 k6 k7 k8
Answer: Acl is equal to
     
0 1 1 1 1 0   k1 k2 + 1 k3 + 1 k4 + 1
1 0 0 0 0 0 k 1 k 2 k 3 k 4  1 0 0 0 
Acl = A + BK =  1 1 0 0 + 0 1 k 5 k 6 k 7 k 8 =  k 5 + 1 k 6 + 1
    .
k7 k8 
1 1 1 0 0 1 k5 + 1 k6 + 1 k7 + 1 k8
The first diagonal matrix is
 
k k2 + 1
Acl1 = 1 ,
1 0
where
Det( Acl1 − λI ) = λ2 − k1 λ − (k2 + 1),
such that it is equal to

(λ − 2)(λ − 3) = λ2 − 5λ + 6 = λ2 − k1 λ − (k2 + 1) = 0, ⇒ k1 = 5, k2 = −7.


The second diagonal matrix is
 
k7 k8
Acl2 = ,
k7 + 1 k8
where
Det( Acl2 − λI ) = λ2 − (k7 + k8 )λ − k8 ,
such that it is equal to

(λ)(λ − 1) = λ2 − λ = λ2 − (k7 + k8 )λ − k8 = 0, ⇒ k7 = 1, k8 = 0.
With the remaining terms k3 = k4 = k5 = k6 = −1. Hence, the control law is
 
5 −7 −1 −1
u(t) = x ( t ).
−1 −1 1 0

4. Answer the following questions for this system:


   
1 0 1 0
x ( k + 1) =  −1 −1 1 x ( k ) + 0 u ( k ).
0 0 2 1

2
(a) Is the system controllable? Show this result via the first three controllability tests. You can
use MATLAB in this problem to find the eigenvalues and the eigenvectors.
(b) Is the system stabilizable? If so, design a state feedback controller u(k) = −Kx (k) that would
shift the unstable eigenvalues to stable locations which are λcl ( A) = {−1, −0.5, 0.5}. Can
you obtain such a state feedback controller? Here K ∈ R1×3 .
(c) Consider that x (0) = 0. Obtain the reachable subspace Rk of the system at k = 1, 2, 3, . . ..
Recall that the reachable subspace is

Rk = Range-Space( B AB A2 B · · · Ak−1 B ).
 

  sequence (u(0), u(1), . . . , u(n − 1)) that can drive the system from
(d) Can you find a control
1
x (0) = 0 to x (n) = 1 in the least possible time-steps n. You can start by trying n = 1 then
0
n = 2, etc...
Answer:
(a) First, by the controllability matrix, we have
 
0 1 3
A2 B = 0
 
Co = B AB 1 0 .
1 2 4

Since Rank(Co ) = 3, then the system is controllable.


Next, the eigenvalues of A are Λ = {−1, 1, 2}. By using the PBH test, we get
 
  2 0 −1 0
• Rank( λ1 I − A B ) = Rank 1 0 −1 0 = 3
0 0 −3 1
 
  0 0 −1 0
• Rank( λ2 I − A B ) = Rank 1 2 −1 0 = 3
0 0 −1 1
 
  1 0 −1 0
• Rank( λ3 I − A B ) = Rank 1 3 −1 0 = 3
0 0 0 1
Since all the tests give full rank, then the system is controllable.
Last, the left eigenvectors of A are
 
0.4082 0.7071 0
W =  0.8165 0 0 ,
−0.4082 −0.7071 1

such that, multiplying them with B yields


 
0
• W (1)> B = 0.4082 0.8165 −0.4082 0 = −0.4082
 

1
 
0
• W (2)> B = 0.7071 0 −0.7071 0 = −0.7071
 

1
 
 0
• W (3)> B = 0 0 1 0 = 1.


1
Since all of them are nonzero, then the system is controllable.

3
(b) Since the system is controllable, then it is also stabilizable. The closed loop system can be
written as
     
1 0 1 0   1 0 1
Acl = A − BK = −1 −1 1 − 0 k1 k2 k3 =  −1 −1 1 .
0 0 2 1 −k1 −k2 2 − k3

The characteristic equation of Acl is

λ3 + (−k2 + k3 − 2)λ2 + (k1 − 1)λ + (k1 − k3 + 2) = 0.

For the closed-loop to have poles at {−1, −0.5, 0.5}, then

1 1
λ3 + (−k2 + k3 − 2)λ2 + (k1 − 1)λ + (k1 − k3 + 2) = λ3 + λ2 − λ − = 0,
4 4
Which gives
3 
K= 4 0 3 .

(c) First, since the matrix A has size of 3 × 3, let’s see its reachable subspace for k = 3.
 
0 1 3
Range( B AB A2 B ) = Range 0 1 0 .
 

1 2 4

By using the reduced column echelon form, we get


         
0 1 3 1 0 0 1 0 0
Range 0 1 0 = Range 0 1 0 = a 0 + b 1 + c 0 , a, b, c ∈ R.
1 2 4 0 0 1 0 0 1

Since for k = 3 the reachable subspace spans R3 , then for any k ≥ 3, the reachable subspace
also spans R3 .
(d) Since the reachable subspace spans R3 for k = 3, then the states can be transferred to any-
>
where in R3 for k = 3. Moreover, since B = 0 0 1 , there is no control input that is able

 >
to transfer the states to 1 1 0 at k = 1. However, at k = 2, we have

x (2) = Bu(1) + ABu(0)


     
1 0 1
1 = 0 u (1) + 1 u (0).
0 1 2

From the equation above, one can set u(1) = −2 and u(0) = 1 for the states to reach
 >
1 1 0 .

5. Show that if we discretize a system ẋ (t) = Ax (t) + Bu(t) to x (k + 1) = Ãx (k) + B̃u(k ), then if
the discretized system defined by ( Ã, B̃) is controllable, then so should the continuous system
defined by the pair ( A, B).
Hint: You can prove this result by contradiction and by using the eigenvector test for controlla-
bility.
Answer: Suppose the continuous time is uncontrollable, then there exist at least one left eigenvec-
tor that corresponds to a particular eigenvalue λ j such that w>
j B = 0. Without loss of generality,
the forward Euler approximation of the continuous time is given as

Ā = I + AT, B̄ = BT,

4
for a nonzero sampling time T > 0. In this representation, let λ be the eigenvalue of A. Then,
without loss of generality, assuming that A is diagonalizable

Ā = I + AT
= T̂ ( I ) T̂ −1 + ( T̂D T̂ −1 ) T
= T̂ ( I ) T̂ −1 + T̂ ( DT ) T̂ −1
= T̂ ( I + DT ) T̂ −1 .

From the above, we get λ̄ = 1 + λT or equivalently λ = λ̄− 1


T . Notice that, the eigenvectors of
discrete-time systems is similar to that of continuous time systems because

wi> ( Ā − λ̄i I ) = wi> (( I + AT ) − λ̄i I )


λ̄i − 1
= wi> ( A − ( )I)
T
= wi> ( A − λi I ) = 0.
. Since the discrete-time system is controllable, then

wi> B̄ 6= 0, where wi> ( Ā − λ̄i I ) = 0, ∀i = 1, . . . , N.

Since wi> B̄ = wi> ( BT ) 6= 0 for all i, then for nonzero T, we must have wi> B 6= 0 for all i. This
contradicts the supposition hence completes the proof. .
6. For a CT LTI system with
   
−1 1 0 0

 −1 1 

0
 2 
 −1  , B =  α1
  −1
A= 

 −1 

1
 α2 

 2 1 0 0 
0 2 0 −1

obtain condition(s) on α1 and α2 such that the pair ( A, B) is controllable. You can use any test that
you want, but the choice of the test might incur longer time to come to the condition—choose
wisely!
Answer: Clearly, A is in Jordan canonical form with 2 distinct eigenvalues, while the remaining
eigenvalues are repeated. The eigenvalues of A are −1 and 2. We can use the PBH test to test the
controllability for the two eigenvalues. For λ = −1, the reduced row echelon form is given as
 
0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 −2 
 0 0 0 0 1 1 0
 

3 0 
λI − A B =  0 0 0 0 0 1 0 1
,

 3 
0 0 0 0 0 0 1 α2 
0 0 0 0 0 0 0 −1 − α1 α2

whereas for λ = 2
− 13
 
1 0 0 0 0 0 0
0
 1 − 31 0 0 0 0 2
3



λI − A
 0
B =
0 1 0 0 0 α1
3 − 13 
α2  .

0 1
 0 0 1 0 0 3 3 
0 0 0 0 0 1 0 0 
0 0 0 0 0 0 0 1

For the system to be controllable, then each matrix must be full rank. Consequently,

−1 − α1 α2 6= 0 ⇔ α1 α2 6= −1.

5
7. Consider the following system
   
2 1 1
ẋ (t) = x (t) + u ( t ).
0 −1 −3

(a) Is the system controllable?


(b) Find the controllability subspace.
(c) Is the system stabilizable?
(d) Is there a state feedback gain such that A − BK has evalues {−1, 1}?
 >  
(e) Suppose that x (0) = 1 0 and u(t) = 0. Find y(t) if y(t) = Cx (t) = 3 1 x ( t ).

Answer:

(a) No, the system is uncontrollable because


 
  1 −1
Rank B AB = Rank = 1.
−3 3

(b) using the reduced row echelon, we get


     
1 −1 1 0 1
Range = Range =c , c ∈ R.
−3 3 −3 0 −3

(c) No, because according to the PBH test for unstable eigenvalue, since the eigenvalues of A
are -1 and 2, we get
 
  0 −1 1
Rank( 2I − A B ) = Rank = 1.
0 3 −3

(d) The closed-loop dynamics is


     
2 1 1   2 − k1 1 − k2
Acl = A − BK = − k1 k2 = ,
0 −1 −3 3k 1 −1 + 3k2

whereas its characteristic polynomial is

Det( Acl − λI ) = λ2 − +(k1 − 3k2 − 1)λ − (−2k1 + 6k2 − 2) = 0.

The characteristic polynomial with desired eigenvalues at {−1, 1} is λ2 − 1 = 0. From these


two equations, we get a system of linear equations

k1 − 3k2 = 1
k1 − 3k2 = 0.

Since the above linear equations are inconsistent, it has no solution. Hence there is no state
feedback that can move the closed-loop eigenvalues to {−1, 1}.
(e) To answer this problem, we need to compute the matrix exponential for A. Since A is diag-
onalizable, then
2t −t 
1 −0.3162 e2t 0
    
e At = Te Dt T −1 =
1 0.3333
= e2t e3 − e 3 .
0 0.9487 0 e−t 0 1.0541 0 e−t

We finally get

e2t −t  
At
y(t) = Cx (t) = Ce x (0) = 3

1
 e2t
3 − e3 1
= 3e2t .
0 e−t 0

6
8. Coding problem—horray! Ok, so in this problem I want you to write MATLAB function that
takes as an input (potentially large) matrices A and B and checks for the four tests of controlla-
bility (T1—T4) we learned in class. You can assume that the system is continuous time. Some
instructions:
(a) Implement the four tests as discussed in class in the most efficient way.
(b) The function should return a 4-digit binary string with {1, 1, 1, 1} denoting that the sys-
tem is controllable and the four tests all yielded a ’1’ meaning the system is controllable or
{0, 0, 0, 0} denoting the system is not controllable. If your code returns something other than
that, then you’ve probably done something wrong.
(c) The function should also return the computational time required to run each of the methods
(T1—T4). You should start by trying your code for random small-scale dynamic systems,
and then try a rather large-scale system with millions of states and tens of thousands of
control inputs. The computational time should be returned in an array with four numbers—
each number denoting how many seconds it took to run each test. See MATLAB’s help files
to compute computational time for any function.
(d) Your MATLAB function essentially has four other functions that you call for each test. You
can assume that t f = 10 for Test 4 (the Gramian test).
(e) I’ll give extra credits how try hard and do a good job.
(f) Please upload: (a) a PDF for the solutions of the homework, and (b) a single m-file with the
code that returns the above outputs. Not two PDFs and four m-files, a single PDF and a
single m-file—please. :)

Answer: The MATLAB code for the function is given as follows


%Homework 6, Problem 8
%Author: Sebastian A. Nugroho

function [Out,Time] = Hw6_Pr8_Sebastian(A,B)

%Dimension
n = size(A,1);
m = size(B,2);

%Initialization
Out = [0 0 0 0];
Time = [0 0 0 0];

%First method - Controllability matrix


tic;
X = B;
Co = [X];
for i = 1:n-1
Y = A*X;
Co = [Co Y];
X = Y;
end
tol = 10^6;
Co(isnan(Co)) = 0;
Co(~isfinite(Co)) = 10^6;
if rank(Co,tol) == n
Out(1) = 1;
else
Out(1) = 0;
end
Time(1) = toc;

7
%Second method - PBH test
tic;
eigA = eig(A);
I = eye(n);
isCon = 1;
for i = 1:n
if rank([eigA(i)*I-A B]) ~= n
isCon = 0;
break;
end
end
Out(2) = isCon;
Time(2) = toc;

%Third method - Left eigenvector


tic;
[V,D,W] = eig(A);
I = eye(n);
isCon = 1;
for i = 1:n
wt = W(:,i);
if isempty(wt’*B) == true
isCon = 0;
break;
end
end
Out(3) = isCon;
Time(3) = toc;

%Fourth method - Controllability gramian


tic;
f = @(tau) expm(A*tau)*B*B’*expm(A’*tau);
fx = integral(f,0,10,’ArrayValued’,true);
if (det(fx) == 0)
Out(4) = 0;
else
Out(4) = 1;
end
Time(4) = toc;

end
For example, for n = 500 and m = 50, it returns
Out =

1 1 1 1

Time =

2.7061 46.1331 0.2170 36.8057

You might also like