%非线性不确定系统的鲁棒滑模观测器设计
clear
clc
A=[-1 -1 0;
0 -2 -1;
0 0 -3;];
B=[-1 0;
0 1;
0 0;];
C=[0 1 -1;
1 0 0;];
x=[0.2;
0.3;
1;];
x_est=[0;0;0.2;];
u=[0;0];
t=0;
Dt=0.001;
n=1;
for i=1:10000
ee=[0.2*sin(2*pi*t);
0.5*cos(2*pi*t);];
f=B*ee;
Dx=A*x+B*u+f;
x=x+Dx*Dt;
e1=x_est(1)-x(1);
e2=x_est(2)-x(2);
e3=x_est(3)-x(3);
e=[e1;e2;e3];
%s1=e1+2*e2-2*e3;
%s2=e2-e3;
G=[1 0;0 3;-7 0];
F=[2 1;1 0];
s=F*C*e;
M=F*C;
if norm(s'*M*B)==0
v=[0;0];
else
v=-(s'*M*B)'/norm(s'*M*B);%*(norm(s)*norm(M*B)*(10*norm(u))+0.5*(0.5)^1*(norm(s))^(2*1));
end
Dx_est=A*x_est+B*u-G*(C*x_est-C*x)+B*v;
x_est=x_est+Dx_est*Dt;
x_store(:,n)=x;
x_est_store(:,n)=x_est;
e_store(:,n)=e;
v_store(:,n)=v;
t=t+Dt;
n=n+1;
end
figure(1)
subplot(1,3,1)
plot((1:n-1)*Dt,x_store(1,:),(1:n-1)*Dt,x_est_store(1,:))
title('x1')
legend('x1_real','x1_est')
subplot(1,3,2)
plot((1:n-1)*Dt,x_store(2,:),(1:n-1)*Dt,x_est_store(2,:))
title('x1')
legend('x2_real','x2_est')
subplot(1,3,3)
plot((1:n-1)*Dt,x_store(3,:),(1:n-1)*Dt,x_est_store(3,:))
title('x1')
legend('x2_real','x2_est')
figure(2)
plot((1:n-1)*Dt,e_store(1,:),(1:n-1)*Dt,e_store(2,:))
title('error')
legend('e1','e2')
figure(3)
plot((1:n-1)*Dt,v_store(1,:),(1:n-1)*Dt,v_store(2,:))
title('control')
legend('v1','v2')
评论0