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

📄 yunxing2c3.m

📁 这些程序都是经过本人和许许多多工作过学习过的老师同学
💻 M
字号:
%***********加上x4,x5,x6后,且观测值y1,y2,y3,y4,y5为已知,sWfx,sWfy,sWfz扩充为状态变量的情况下可观测性的仿真**********

clc
clear all

[t,y]=ode45('observability2c',[0:2:35*3600],[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]);

yy=zeros(501,12);

%每隔126点保存一次,放在矩阵yy

yy(1,:)=y(1,:);

for j=1:500
    
    for i=2:127
        
        yy(j+1,:)=y(126*j+1,:);
        
    end
    
end   

x1=yy(:,1)*180*60/pi;
x2=yy(:,2)*180*60/pi;
x3=yy(:,3)*180*60/pi;
x4=yy(:,4)*180*60/pi;
x5=yy(:,5)*180*60/pi;
x6=yy(:,6)*180*60/pi;
x7=yy(:,7);
x8=yy(:,8);
x9=yy(:,9)*180*60/pi;
x10=yy(:,10);
x11=yy(:,11);
x12=yy(:,12);

t=0:252/3600:35;

%重力加速度

g=9.80; 

%各轴向的地速分量

Vx=8.0;
Vy=8.0; 
Vz=0.0;

%地球的半径

R=6371020.0; 

%当地的纬度角

angle=pi/4; 

%地球自转角速度

Wie=7.2921158e-5; 

%所测到各轴向的比力信息

fx=(2*Wie*cos(angle)+Vx/R)*Vz-(2*Wie*sin(angle)+Vx*tan(angle)/R)*Vy;
fy=(2*Wie*sin(angle)+Vx*tan(angle)/R)*Vx+Vy*Vz/R;    
fz=-(2*Wie*cos(angle)+Vx/R)*Vx-Vy^2/R+g;


%加速度计的漂移误差

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(1)

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

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

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

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

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

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

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

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

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

figure(2)

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

⌨️ 快捷键说明

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