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

📄 kalman.m

📁 利用kalman滤波器对具有随机加速度的物体运动路线的进行信号采样
💻 M
字号:
% kalman filtering

load initial_track  s; % y:initial data,s:data with noise
T=0.1;

% yp denotes the sample value of position
% yv denotes the sample value of velocity
% Y=[yp(n);yv(n)];
% error deviation caused by the random acceleration 
% known data
Y=zeros(2,200);
Y0=[0;1];
Y(:,1)=Y0;
A=[1 T
    0 1];          
B=[1/2*(T)^2 T]';
H=[1 0];

C0=[0 0
    0 1];
C=[C0 zeros(2,2*199)];
Q=(0.25)^2; 
R=(0.25)^2; 


% kalman algorithm ieration
for n=1:200
    i=(n-1)*2+1;
    K=C(:,i:i+1)*H'*inv(H*C(:,i:i+1)*H'+R);
    Y(:,n)=Y(:,n)+K*(s(:,n)-H*Y(:,n));
    Y(:,n+1)=A*Y(:,n);
    C(:,i:i+1)=(eye(2,2)-K*H)*C(:,i:i+1);
    C(:,i+2:i+3)=A*C(:,i:i+1)*A'+B*Q*B';
end

% the diagram of position after filtering
figure(3) 
t=0:0.1:20;
yp=Y(1,:);A
plot(t,yp,'+');
axis([0 20 0 20]);
xlabel('time');
ylabel('yp position');
title('the track after kalman filtering');

% the diagram of velocity after filtering
figure(4) 
yv=Y(2,:);
plot(t,yv,'+');
xlabel('time');
ylabel('yv velocity');
title('the velocity caused by random acceleration');




    
    
    
   

⌨️ 快捷键说明

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