Vous êtes sur la page 1sur 11

Question 3 – TH3

7)
syms s
A=[-3 1 0;1 -2 1;0 1 -3]
B=[1;0;0]
C=[0 0 1]
D=0
disp('----FSFB----')
P1=-10+5i
P2=-10-5i
P3=-15
G=place(A,B,[P1,P2,P3])
E=[0 0;1 0;-3 1];
Ac=A-B*G
M=inv(Ac)
N=inv(C*M*B)
G0=N*C*M*E
GG=[G G0]
AA=[A E;0 0 0 0 0;0 0 0 0 0];
BB=[B;0;0];
CC=[C 0 0];
disp('***FOO***')
kt=place(AA',CC',[-20+10i,-20-10i,-30,-15,0])
K=kt'
disp('***compensator***')
Ach=AA-BB*GG-K*CC
Rc=inv(s*eye(5)-Ach)
Ds=GG*Rc*K
Ds=collect(Ds,s)
pretty(Ds)
disp('***check via control toolbox***')
comp=ss(Ach,K,GG,0)
zc=zero(comp)
pc=pole(comp)
plant=ss(A,B,C,0)
Fwd=comp*plant
H=feedback(Fwd,1)
zero(H)
pole(H)
disp('***root locus***')
figure(1)
rlocus(Fwd)
figure(2)
disp('***step response***')
step(H),grid
Root Locus
80

60

40
Imaginary Axis (seconds-1)

20

-20

-40

-60

-80
-120 -100 -80 -60 -40 -20 0 20 40 60
-1
Real Axis (seconds )

Step Response
1.8

1.6

1.4

1.2

1
Amplitude

0.8

0.6

0.4

0.2

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
Time (seconds)
Question 4 – PCA
PCA Part 7

M code

-10+5i,-10-5i,-20+10i,-20-10i

syms s
A=[0 0 1 0;0 0 0 1;0 -3.924 -4 0;0 -54.93 16 0];
B=[0;0;1;-4];
C=[1 0 0 0;0 1 0 0];
D=[0;0];

disp('----FSFB----')
G=[884.9432 -121.2817 208.3864 38.0966];
disp('---FOO---')
kt=place(A',C',[-40+30i,-40-30i,-60+20i,-60-20i]);
K=kt';
disp('---Compensator---')
Ach=A-B*G-K*C;
Rc=inv(s*eye(4)-Ach);
Ds=G*Rc*K;
Ds=collect(Ds,s);
pretty(Ds);
disp('---Check via Control Toolbox---')
comp=ss(Ach,K,G,0);
zc=zero(comp);
pc=pole(comp);
plant=ss(A,B,C,0);
Fwd=comp*plant;
H=feedback(Fwd,1);
zero(H);
pole(H);
disp('***root locus***')
figure(1)
rlocus(Fwd)
figure(2)
disp('***step response***')
step(H),grid

plant=ss(A,B,C,0)
obs=ss(Ach,B,C,0)
[u,t] = gensig('square',4,10,0.1);
[y,t,x] = lsim(plant,u,t)
[yy,t,xx] = lsim(obs,u,t)
plot(t,x)
plot(t,xx)

92.6+9.1i 3.9+103.4i 2355.9+874.4i 311.2+3365.6i


Root Locus
400

300

200

100
Imaginary Axis (seconds-1)

-100

-200

-300

-400
-300 -200 -100 0 100 200 300 400
Real Axis (seconds -1)

Step Response
2.5

1.5
Amplitude

0.5

-0.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
Time (seconds)

Original States for the plant


20

15

10

-5

-10

-15
0 1 2 3 4 5 6 7 8 9 10

Plot of the observer estimates xhat

-3
x 10
8

-2

-4

-6

-8

-10

-12
0 1 2 3 4 5 6 7 8 9 10

Second set of poles

-10,-15,-20,-30

syms s
A=[0 0 1 0;0 0 0 1;0 -3.924 -4 0;0 -54.93 16 0]
B=[0;0;1;-4]
C=[1 0 0 0;0 1 0 0]
D=[0;0]
disp('***fsfb***')
G=[1274.3 -167.7 314.6 60.9]
disp('***FOO***')
kt=place(A',C',[-40+30i,-40-30i,-60+20i,-60-20i])
K=kt'
disp('***compensator***')
Ach=A-B*G-K*C
Rc=inv(s*eye(4)-Ach)
Ds=G*Rc*K
Ds=collect(Ds,s)
pretty(Ds)
disp('***check via control toolbox***')
comp=ss(Ach,K,G,0)
zc=zero(comp)
pc=pole(comp)
plant=ss(A,B,C,0)
Fwd=comp*plant
H=feedback(Fwd,1)
zero(H)
pole(H)
disp('***root locus***')
figure(1)
rlocus(Fwd)
figure(2)
disp('***step response***')
step(H),grid

plant=ss(A,B,C,0)
obs=ss(Ach,B,C,0)
[u,t] = gensig('square',4,10,0.1);
[y,t,x] = lsim(plant,u,t)
[yy,t,xx] = lsim(obs,u,t)
plot(t,x)
plot(t,xx)

Root Locus
400

300

200

100
Imaginary Axis (seconds-1)

-100

-200

-300

-400
-300 -200 -100 0 100 200 300
Real Axis (seconds -1)
Step Response
2.5

1.5

1
Amplitude

0.5

-0.5

-1
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 0.5
Time (seconds)

Plot of original states

20

15

10

-5

-10

-15
0 1 2 3 4 5 6 7 8 9 10

Plot of observer states – Estimates


-3
x 10
6

-2

-4

-6

-8
0 1 2 3 4 5 6 7 8 9 10

PCA Part 8

A=[0 0 1 0;0 0 0 1;0 -3.924 -4 0;0 -54.93 16 0]


B=[0;0;1;-4]
c=[1 0 0 0;0 1 0 0]
d=[0;0]

A11=[0 0;0 0]
A12=[1 0 ; 0 1]
A21=[0 -3;0 -54.93]
A22=[-4 0;16 0]
B1=[0;0]
B2=[1;-4]
AA=[A11 A12;A21 A22]
BB=[B1;B2]
CC=[1 0 0 0;0 1 0 0]
plant=ss(AA,BB,CC,[0])
disp('***Control Gains***')
G1=884.94
G2=-121.2817
G3=208.3864
G4=38.09
GG1=[884.9432 -121.2817]
GG2=[208.3864 38.0966]
disp('observer')
Lt=place(A22',A12',[-40+30i,-40-30i])
L=Lt'
F=A22-L*A12
J=A21-L*A11+F*L
H=B2-L*B1
disp('Compensator')
Ac=F-H*GG2
Bc=J-H*(GG1+GG2*L)
Cc=GG2
Dc=GG1+GG2*L
comp=ss(Ac,Bc,Cc,Dc)
pc=pole(comp)
zc=zero(comp)
DD=tf(comp)
disp('closed loop')
Fwd=plant*comp
FS=tf(Fwd)
figure(1)
rlocus(Fwd)
H=feedback(Fwd,1)
clpoles=pole(H)
figure(22)
step(H)

plant=ss(AA,BB,CC,0);
C=[1 0;0 1];
obs=ss(Ac,B1,C,0);
[u,t] = gensig('square',4,10,0.1);
[y,t,x] = lsim(plant,u,t)
[yy,t,xx] = lsim(obs,u,t)

Simulation
Plots without compensator for x1 and x2 and x1 hat and x2 hat
State estimates

Centres d'intérêt liés