Homework6 Sol Sebastian
Homework6 Sol Sebastian
Homework6 Sol Sebastian
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
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
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
(λ)(λ − 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
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
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
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
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
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 .
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
Answer:
(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
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. :)
%Dimension
n = size(A,1);
m = size(B,2);
%Initialization
Out = [0 0 0 0];
Time = [0 0 0 0];
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;
end
For example, for n = 500 and m = 50, it returns
Out =
1 1 1 1
Time =