Professional Documents
Culture Documents
Problem 2: WC - 2 Solves For The Controllability Grammian at T 2
Problem 2: WC - 2 Solves For The Controllability Grammian at T 2
P 2.1
clc
clear all
A=[-0.5 0;0 -1];
B=[0.5 1]';
C=[1 0;0 1];
D=[0 0]';
x0=[5 -2]';
Contr=ctrb(A,B)
Contr = 2×2
0.5000 -0.2500
1.0000 -1.0000
wc_2=integral(w,0,2,'ArrayValued',true)
wc_2 = 2×2
0.2162 0.3167
0.3167 0.4908
%wc_inv_2=wc_2^-1
syms t
t2=2;
ut_2= vpa(-B'*expm(A'*(t2-t))*wc_2^(-1)*expm(A*t2)*x0 , 7)
ut_2 =
Part 2.2
wc_5 solves for the controllability grammian at t=5
wc_5=integral(w,0,5,'ArrayValued',true)
wc_5 = 2×2
0.2483 0.3331
1
0.3331 0.5000
t5=5;
ut_5=vpa(-B'*expm(A'*(t5-t))*wc_2^(-1)*expm(A*t5)*x0 , 7)
ut_5 =
Part 2.3
t_2=linspace(0,2,100);
ut_2a= @(t) -B'*expm(A'.*(t2-t))*wc_2^(-1)*expm(A.*t2)*x0;
ut_2b=zeros(length(t_2),1);
for i=1:length(t_2)
ut_2b(i)=vpa(-B'*expm(A'*(t2-t_2(i)))*wc_2^(-1)*expm(A*t2)*x0,3);
end
%[b,a]=ss2tf(A,B,C,D);
%G=[tf([b],[a])]
G=[tf(ss(A,B,C,D))]
G =
1
2: -----
s + 1
lsim(G,ut_2b,t_2)
2
the blue curve represents the output x that shows it converging towards 0 with input u defined in grey.
t_5=linspace(0,5,100);
ut_5a= @(t) -B'*expm(A'.*(t5-t))*wc_2^(-1)*expm(A.*t5)*x0;
ut_5b=zeros(length(t_5),1);
for i=1:length(t_5)
ut_5b(i)=vpa(-B'*expm(A'*(t5-t_5(i)))*wc_2^(-1)*expm(A*t5)*x0,3);
end
%[b,a]=ss2tf(A,B,C,D);
G=[tf(ss(A,B,C,D))]
G =
1
2: -----
s + 1
3
lsim(G,ut_2b,t_5)
For both cases t=2 and t=5 we notice that with t=5 the input is a lot more drastic early on and takes a much
harder push compared to t=2. Essentially the control may not be the most robust when comparing t=5 to t=2.
Problem 3
Part 3.1
clc
clear all
x=0.5
x = 0.5000
C = 2×2
0.5000 -0.5000
4
0.5000 -0.5000
a1=rref(C)
a1 = 2×2
1 -1
0 0
checking rank deficient of controllability matrix with solution found for alpha
a=rank(C)
a = 1
Part 3.2
clc
clear all
x=0
x = 0
O = 2×2
1 0
-2 1
rank (O)
ans = 2
Problem 4
clc
clear all
A=[1 0 2; 4 1 6; -3 0 -4];
B=[-1 1 1]';
C=[2 1 3];
5
D=[0];
Co = 3×3
-1 1 -1
1 3 1
1 -1 1
r_c=rank(Co)
r_c = 2
p_inv = 3×3
-1 1 1
1 3 0
1 -1 0
Ahat_c=(p_inv^-1)*A*p_inv
Ahat_c = 3×3
0 1.0000 -1.2500
1.0000 0 1.7500
0 0 -2.0000
Bhat_c=(p_inv^-1)*B
Bhat_c = 3×1
1
0
0
Chat_c=C*p_inv
Chat_c = 1×3
2 2 2
Abar = 3×3
-2.0000 0.0000 -0.0000
8.6603 -0.3333 1.8856
-0.0000 0.4714 0.3333
Bbar = 3×1
0
0.0000
1.7321
Cbar = 1×3
3.5355 0.4082 1.1547
T = 3×3
0.7071 -0.0000 0.7071
0.4082 0.8165 -0.4082
-0.5774 0.5774 0.5774
6
k = 1×3
1 1 0
Ob=obsv(A,C)
Ob = 3×3
2 1 3
-3 1 -2
7 1 8
r_o = 2
p=[Ob(2:3,1:3); 1 0 0 ]
p = 3×3
-3 1 -2
7 1 8
1 0 0
ans = 3
Ahat_o=p*A*p^-1
Ahat_o = 3×3
0 1.0000 0
2.0000 -1.0000 0
-0.2000 0.2000 -1.0000
Bhat_o=p*B
Bhat_o = 3×1
2
2
-1
Chat_o=C*p^-1
Chat_o = 1×3
0.5000 0.5000 0
Part 4.4
G=tf(ss(A,B,C,D))
7
G =
2 s^2 + 6 s + 4
-------------------
s^3 + 2 s^2 - s - 2
Problem 5
Part 5.1
clc
clear all
A=[2 1 0; 0 3 1; 1 0 1];
B=[1 0 2]';
C=[2 2 1];
D=[0];
Co=ctrb(A,B)
Co = 3×3
1 2 6
0 2 9
2 3 5
r_c=rank(Co)
r_c = 3
Part 5.2
Ob=obsv(A,C)
Ob = 3×3
2 2 1
5 8 3
13 29 11
r_o=rank(Ob)
r_o = 3
8
9