⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yunxing2c2.m

📁 这些程序都是经过本人和许许多多工作过学习过的老师同学
💻 M
📖 第 1 页 / 共 2 页
字号:
grid on;

figure(7)

subplot(3,1,1)
plot(t,est116,'b');
xlabel('time/h');
grid on;
subplot(3,1,2)
plot(t,est117,'b');
xlabel('time/h');
grid on;

%加速度计的漂移误差

ax2=1e-4*g; 
ay2=1e-4*g; 

%陀螺仪漂移误差

ex2=0.1*pi/(180*3600);
ey2=0.1*pi/(180*3600);
ez2=0.1*pi/(180*3600);


%求出A阵

A2=zeros(12);

A2(1,2)= Vx*tan(angle)/R+Wie*sin(angle);
A2(1,3)=-Vx/R-Wie*cos(angle);
A2(1,8)=-1/R;
A2(2,1)=-Vx*tan(angle)/R-Wie*sin(angle);
A2(2,3)=-Vy/R;
A2(2,7)=1/R;
A2(2,9)=-Wie*sin(angle);
A(3,1)=Vx/R+Wie*cos(angle);
A(3,2)=Vy/R;
A2(3,7)=tan(angle)/R;
A2(3,9)=Wie*cos(angle)+Vx*sec(angle)^2/R;
A2(4,10)=1;
A2(5,11)=1;
A2(6,12)=1;
A2(7,2)=-fz;
A2(7,3)=fy; 
A2(7,7)=(Vy*tan(angle)-Vz)/R;
A2(7,8)=2*Wie*sin(angle)+Vx*tan(angle)/R; 
A2(7,9)=2*Wie*sin(angle)*Vz+(2*Wie*cos(angle)+Vx*sec(angle)^2/R)*Vy;
A2(8,1)=fz;
A2(8,3)=-fx;
A2(8,7)=-2*Wie*sin(angle)-2*Vx*tan(angle)/R;
A2(8,8)=-Vz/R;
A2(8,9)=-2*Wie*cos(angle)*Vx-Vx^2*sec(angle)^2/R;
A2(9,8)=1/R;

B2=eye(12);

D2=zeros(5,12);

%求出C阵

C2=zeros(5,12);

C2(1,7)=1;
C2(2,8)=1;
C2(3,1)=-1;
C2(3,4)=1;
C2(4,2)=-1;
C2(4,5)=1;
C2(5,3)=-1;
C2(5,6)=1;

%离散化

[a2,b2,c2,d2]=c2dm(A2,B2,C2,D2,2);

%kalman滤波方程的定义

estX2=zeros(12,127);
realX2=zeros(12,127);
PP2=zeros(12,12,126);
P2=zeros(12,12,127);
K2=zeros(12,5,127);
Z2=zeros(5,127);
estXX2=zeros(12,501);
CP2=zeros(12,12,501);

%系统的观测噪声的协方差强度阵

RR2=zeros(5);

RR2(1,1)=0.01;
RR2(2,2)=0.01;
RR2(3,3)=(pi/(60*180))^2;
RR2(4,4)=(pi/(60*180))^2;
RR2(5,5)=(3*pi/(60*180))^2;

%置系统噪声方差阵Q阵

Q2=zeros(12);

Q2(1,1)=(0.01*pi/(180*3600))^2;
Q2(2,2)=(0.01*pi/(180*3600))^2;
Q2(3,3)=(0.01*pi/(180*3600))^2;
Q2(4,4)=(0.01*pi/(180*3600))^2;    
Q2(5,5)=(0.01*pi/(180*3600))^2;
Q2(6,6)=(0.01*pi/(180*3600))^2;
Q2(7,7)=(1e-5*g)^2;             
Q2(8,8)=(1e-5*g)^2;

%系统噪声

w2=[0.01*pi/(180*3600)*randn(1) 0.01*pi/(180*3600)*randn(1) 0.01*pi/(180*3600)*randn(1) 0.01*pi/(180*3600)*randn(1) 0.01*pi/(180*3600)*randn(1) 0.01*pi/(180*3600)*randn(1) 1e-5*g*randn(1) 1e-5*g*randn(1) 0 0 0 0]';

%量测噪声

v2=[0.1*randn(1) 0.1*randn(1) pi/(60*180)*randn(1) pi/(60*180)*randn(1) 3*pi/(60*180)*randn(1)]';

%状态变量的初始值

estX2(:,1)=[0 0 0 0 0 0 0 0 0 0 0 0 ]';
realX2(:,1)=[3*pi/(60*180) 3*pi/(60*180) 5*pi/(60*180) 5*pi/(60*180) 5*pi/(60*180) 6*pi/(60*180) 0.1 0.1 2*pi/(60*180) 0 0 0]';

%协方差矩阵的初始值

P2(1,1,1)=(3*pi/(60*180))^2;
P2(2,2,1)=(3*pi/(60*180))^2;
P2(3,3,1)=(5*pi/(60*180))^2;
P2(4,4,1)=(5*pi/(60*180))^2;
P2(5,5,1)=(5*pi/(60*180))^2;
P2(6,6,1)=(6*pi/(60*180))^2;
P2(7,7,1)=0.01;
P2(8,8,1)=0.01;
P2(9,9,1)=(2*pi/(60*180))^2;
P2(10,10,1)=0.1^2;
P2(11,11,1)=0.125^2;
P2(12,12,1)=0.001^2;

%确定的干扰项

CP2(:,:,1)=P2(:,:,1);

f2=[-ex2 -ey2 -ez2 ex2 ey2 ez2 ax2 ay2 0 0 0 0]';

for j=1:500
    
   for i=2:127
       
     PP2(:,:,i)=a2*P2(:,:,i-1)*a2'+Q2;
     K2(:,:,i)=PP2(:,:,i)*c2'*inv(c2*PP2(:,:,i)*c2'+RR2);
     realX2(:,i)=a2*realX2(:,i-1)+b2*f2+w2;
     Z2(:,i)=c2*realX2(:,i)+v2;
     estX2(:,i)=a2*estX2(:,i-1)+b2*f2+K2(:,:,i)*(Z2(:,i)-c2*(a2*estX2(:,i-1)+b2*f2));
     P2(:,:,i)=PP2(:,:,i)-K2(:,:,i)*c2*PP2(:,:,i);
     
   end
   
     P2(:,:,1)=P2(:,:,127);
     realX2(:,1)=realX2(:,127);
     estX2(:,1)=estX2(:,127);
     estXX2(:,j+1)=estX2(:,127);
     CP2(:,:,j+1)=P2(:,:,127);
     
end

for i=1:501
    
    est21(i)=estXX2(1,i)*180*60/pi;
    est22(i)=estXX2(2,i)*180*60/pi;
    est23(i)=estXX2(3,i)*180*60/pi;
    est24(i)=estXX2(4,i)*180*60/pi;
    est25(i)=estXX2(5,i)*180*60/pi;
    est26(i)=estXX2(6,i)*180*60/pi;
    est27(i)=estXX2(7,i);
    est28(i)=estXX2(8,i);
    est29(i)=estXX2(9,i)*180*60/pi;
    est210(i)=estXX2(10,i);
    est211(i)=estXX2(11,i);
    est212(i)=estXX2(12,i);
    
    PPP21(i)=CP2(1,1,i)*(180*60/pi)^2;
    PPP22(i)=CP2(2,2,i)*(180*60/pi)^2;
    PPP23(i)=CP2(3,3,i)*(180*60/pi)^2;
    PPP24(i)=CP2(4,4,i)*(180*60/pi)^2;
    PPP25(i)=CP2(5,5,i)*(180*60/pi)^2;
    PPP26(i)=CP2(6,6,i)*(180*60/pi)^2;
    PPP27(i)=CP2(7,7,i);
    PPP28(i)=CP2(8,8,i);
    PPP29(i)=CP2(9,9,i)*(180*60/pi)^2;
    PPP210(i)=CP2(10,10,i);
    PPP211(i)=CP2(11,11,i);
    PPP212(i)=CP2(12,12,i);
           
end

%画出状态变量的估计值的曲线图

figure(8)

subplot(3,1,1)
plot(t,est21,'b');
xlabel('time/h');
grid on;

subplot(3,1,2)
plot(t,est22,'b');
xlabel('time/h');
grid on;

subplot(3,1,3)
plot(t,est23,'b');
xlabel('time/h');
grid on;

figure(9)

subplot(3,1,1)
plot(t,est24,'b')
xlabel('time/h');
grid on;

subplot(3,1,2)
plot(t,est25,'b');
xlabel('time/h');
grid on;

subplot(3,1,3)
plot(t,est26,'b');
xlabel('time/h');
grid on;

figure(10)

subplot(3,1,1)
plot(t,est27,'b');
xlabel('time/h');
grid on;

subplot(3,1,2)
plot(t,est28,'b');
xlabel('time/h');
grid on;

subplot(3,1,3)
plot(t,est29,'b');
xlabel('time/h');
grid on;

figure(11)

subplot(3,1,1)
plot(t,est210,'b');
xlabel('time/h');
grid on;

subplot(3,1,2)
plot(t,est211,'b');
xlabel('time/h');
grid on;

subplot(3,1,3)
plot(t,est212,'b');
xlabel('time/h');
grid on;

figure(12)

subplot(3,1,1)
plot(t,est11'-x1,'b',t,est21'-x1,'b--');
xlabel('time/h');
grid on;

subplot(3,1,2)
plot(t,est12'-x2,'b',t,est22'-x2,'b--');
xlabel('time/h');
grid on;

subplot(3,1,3)
plot(t,est13'-x3,'b',t,est23'-x3,'b--');
xlabel('time/h');
grid on;

figure(13)

subplot(3,1,1)
plot(t,est14'-x4,'b',t,est24'-x4,'b--');
xlabel('time/h');
grid on;

subplot(3,1,2)
plot(t,est15'-x5,'b',t,est25'-x5,'b--');
xlabel('time/h');
grid on;

subplot(3,1,3)
plot(t,est16'-x6,'b',t,est26'-x6,'b--');
xlabel('time/h');
grid on;

figure(14)

subplot(3,1,1)
plot(t,est17'-x7,'b',t,est27'-x7,'b--');
xlabel('time/h');
grid on;

subplot(3,1,2)
plot(t,est18'-x8,'b',t,est28'-x8,'b--');
xlabel('time/h');
grid on;

subplot(3,1,3)
plot(t,est19'-x9,'b',t,est29'-x9,'b--');
xlabel('time/h');
grid on;

figure(15)

subplot(3,1,1)
plot(t,est113'-x10,'b',t,est210'-x10,'b--');
xlabel('time/h');
grid on;
subplot(3,1,2)
plot(t,est114'-x11,'b',t,est211'-x11,'b--');
xlabel('time/h');
grid on;
subplot(3,1,3)
plot(t,est115'-x12,'b',t,est212'-x12,'b--');
xlabel('time/h');
grid on;

%协方差矩阵的仿真

figure(16)

subplot(3,1,1)
plot(t,PPP11,'b',t,PPP21,'b--');
xlabel('time/h');
grid on;

subplot(3,1,2)
plot(t,PPP12,'b',t,PPP22,'b--');
xlabel('time/h');
grid on;

subplot(3,1,3)
plot(t,PPP13,'b',t,PPP23,'b--');
xlabel('time/h');
grid on;

figure(17)

subplot(3,1,1)
plot(t,PPP14,'b',t,PPP24,'b--');
xlabel('time/h');
grid on;

subplot(3,1,2)
plot(t,PPP15,'b',t,PPP25,'b--');
xlabel('time/h');
grid on;

subplot(3,1,3)
plot(t,PPP16,'b',t,PPP26,'b--');
xlabel('time/h');
grid on;

figure(18)

subplot(3,1,1)
plot(t,PPP17,'b',t,PPP27,'b--');
xlabel('time/h');
grid on;

subplot(3,1,2)
plot(t,PPP18,'b',t,PPP28,'b--');
xlabel('time/h');
grid on;

subplot(3,1,3)
plot(t,PPP19,'b',t,PPP29,'b--');
xlabel('time/h');
grid on;

figure(19)

subplot(3,1,1)
plot(t,PPP110,'b',t,PPP210,'b--');
xlabel('time/h');
grid on;

subplot(3,1,2)
plot(t,PPP112,'b',t,PPP211,'b--');
xlabel('time/h');
grid on;

subplot(3,1,3)
plot(t,PPP112,'b',t,PPP212,'b--');
xlabel('time/h');
grid on;











⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -