ML0015基于Matlab构造无迹卡尔曼滤波器

2021年10月20日 0 条评论 589 次阅读 0 人点赞

%------------------清屏----------------
close all;clear all;  %关闭所有文件,清除所有变量
clc; tic;             %清屏、记录程序开始时间
global Qf n;          %定义全局变量
%------------------初始化--------------
stater0=[220; 1;55;-0.5];     %标准系统初值
state0=[200;1.3;50;-0.3];     %测量状态初值
%--------系统滤波初始化  
p=[0.005 0 0 0;0 0.005 0 0;
   0 0 0.005 0;0 0 0 0.005];  %状态误差协方差初值                             
n=4; T=3;
Qf=[T^2/2 0;0 T;T^2/2 0;0 T];
%--------------------------------------
stater=stater0;state=state0; xc=state;
staterout=[]; stateout=[];xcout=[];
errorout=[];tout=[];
t0=1; h=1; tf=1000;          %仿真时间设置
%---------------滤波算法----------------
for t=t0:h:tf
    [state,stater,yc]=track(state,stater); %轨迹发生器:标准轨迹和输出
    [xc,p]=UKFfiter(@systemfun,@measurefun,xc,yc,p);
    error=xc-stater;              %滤波处理后的误差
    staterout=[staterout,stater];
    stateout=[stateout,state];
    errorout=[errorout,error];
    xcout=[xcout,xc];  
    tout=[tout,t];
end 

提取码:knpw

极寒钛

别给思维设限