Académique Documents
Professionnel Documents
Culture Documents
subplot(6,1,1);
plot(t,X)
legend('X1','X2');
subplot(6,1,2);
Y=[Y ones(size(Y))];
plot(t,Y)
legend('output','input');
AXIS([0 10 0 2])
u=sin(t);
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,3);
plot(t,X)
legend('X1','X2');
subplot(6,1,4);
gar=(sin(t));
Y=[Y gar'];
plot(t,Y)
legend('output','input');
AXIS([0 10 -2 2])
u=square(t);
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,5);
plot(t,X)
legend('X1','X2');
subplot(6,1,6);
gar1=square(t);
Y=[Y gar1'];
plot(t,Y)
legend('output','input');
AXIS([0 10 -2 2])
state=ss(A,B,C,D);
Con=ctrb(state)
Obs=obsv(state)
if det(Con)~=0
disp('System is controllable')
else
disp('System is not controllable')
end
if det(Obs)~=0
disp('System is observable')
else
disp('System is not observable')
end
Con =
0 1
1 -6
Obs =
1 0
0 1
System is controllable
System is observable
PHASE PORTRAIT:
[x1 x2]= meshgrid(-.5:.05:0.5,-0.5:0.05:.5);
x1d=x2;
x2d=-8*x1-6*x2;
quiver(x1,x2,x1d,x2d)
QUESTION 2(A)
A=[0 1;-2 -3];B=[0;1];C=[1 0 ];D=0;
t=0:0.05:20;
u=ones(size(t));
X0=[0 0 ];
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,1);
plot(t,X)
legend('X1','X2');
subplot(6,1,2);
Y=[Y ones(size(Y))];
plot(t,Y)
legend('output','input');
AXIS([0 10 0 2])
u=sin(t);
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,3);
plot(t,X)
legend('X1','X2');
subplot(6,1,4);
gar=(sin(t));
Y=[Y gar'];
plot(t,Y)
legend('output','input');
AXIS([0 10 -2 2])
u=square(t);
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,5);
plot(t,X)
legend('X1','X2');
subplot(6,1,6);
gar1=square(t);
Y=[Y gar1'];
plot(t,Y)
legend('output','input');
AXIS([0 10 -2 2])
QUESTION 2(B)
A=[0 1;-2 -3];B=[0;1];C=[1 0 ];D=0;
t=0:0.05:20;
u=ones(size(t));
X0=[1 2];
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,1);
plot(t,X)
legend('X1','X2');
subplot(6,1,2);
Y=[Y ones(size(Y))];
plot(t,Y)
legend('output','input');
AXIS([0 10 0 2])
u=sin(t);
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,3);
plot(t,X)
legend('X1','X2');
subplot(6,1,4);
gar=(sin(t));
Y=[Y gar'];
plot(t,Y)
legend('output','input');
AXIS([0 10 -2 2])
u=square(t);
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,5);
plot(t,X)
legend('X1','X2');
subplot(6,1,6);
gar1=square(t);
Y=[Y gar1'];
plot(t,Y)
legend('output','input');
AXIS([0 10 -2 2])
QUESTION 3
A=[-1 -.5;1 0];B=[.5;0];C=[1 0 ];D=0;
t=0:0.05:20;
u=ones(size(t));
X0=[0 0];
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,1);
plot(t,X)
legend('X1','X2');
subplot(6,1,2);
Y=[Y ones(size(Y))];
plot(t,Y)
legend('output','input');
AXIS([0 10 0 2])
u=sin(t);
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,3);
plot(t,X)
legend('X1','X2');
subplot(6,1,4);
gar=(sin(t));
Y=[Y gar'];
plot(t,Y)
legend('output','input');
AXIS([0 10 -2 2])
u=square(t);
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,5);
plot(t,X)
legend('X1','X2');
subplot(6,1,6);
gar1=square(t);
Y=[Y gar1'];
plot(t,Y)
legend('output','input');
AXIS([0 10 -2 2])
QUESTION 4
A=[0 1 0;0 0 1;-1 -2 -3];B=[0;0;1];C=[1 0 0];D=0;
t=0:0.05:20;
u=ones(size(t));
X0=[0 0 0];
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,1);
plot(t,X)
legend('X1','X2');
subplot(6,1,2);
Y=[Y ones(size(Y))];
plot(t,Y)
legend('output','input');
AXIS([0 10 0 2])
u=sin(t);
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,3);
plot(t,X)
legend('X1','X2');
subplot(6,1,4);
gar=(sin(t));
Y=[Y gar'];
plot(t,Y)
legend('output','input');
AXIS([0 10 -2 2])
u=square(t);
[Y X]=lsim(A,B,C,D,u,t,X0);
subplot(6,1,5);
plot(t,X)
legend('X1','X2');
subplot(6,1,6);
gar1=square(t);
Y=[Y gar1'];
plot(t,Y)
legend('output','input');
AXIS([0 10 -2 2])
DISCRETE TIME
QUESTION 1
a=[0 1;-2 -3]; b=[0; 1]; c=[1 0]; d=0;
sys=ss(a,b,c,d);
T=0.01;
sysd=c2d(sys,T)
t=0:1:800;
u=[1*ones(size(t))]';
dlsim(sysd.a,sysd.b,sysd.c,sysd.d,u)
a=
x1 x2
x1 0.9999 0.009851
x2 -0.0197 0.9703
b=
u1
x1 4.95e-005
x2 0.009851
c=
x1 x2
y1 1 0
Discrete-time model.
QUESTION 2
a=[0 1;0 -2]; b=[0; 1]; c=[1 0]; d=0;
sys=ss(a,b,c,d);
T=1;
sysd=c2d(sys,T)
t=0:1:800;
u=[1*ones(size(t))]';
dlsim(sysd.a,sysd.b,sysd.c,sysd.d,u)
Result:
a =
x1 x2
x1 1 0.4323
x2 0 0.1353
b =
u1
x1 0.2838
x2 0.4323
c =
x1 x2
y1 1 0
Sampling time: 1
Discrete‐time model.
QUESTION 3
a=[0 1;-2 -3]; b=[0; 1]; c=[3 1]; d=0;
t=0:1:6;
u=[1*ones(size(t))]';
dlsim(a,b,c,d,u)
QUESTION 4
a=[0 1;-0.16 -1]; b=[1; 1]; c=[1 0]; d=0;
t=0:1:30;
u=[1*ones(size(t))]';
dlsim(a,b,c,d,u)