资源简介
主要是一个关于matlab实现粒子滤波的代码,如目标追踪等。

代码片段和文件信息
%% SIR粒子滤波的应用,算法流程参见博客http://blog.csdn.net/heyijia0327/article/details/40899819
clear all
close all
clc
%% initialize the variables
x = 0.1; % initial actual state
x_N = 1; % 系统过程噪声的协方差 (由于是一维的,这里就是方差)
x_R = 1; % 测量的协方差
T = 75; % 共进行75次
N = 100; % 粒子数,越大效果越好,计算量也越大
%initilize our initial prior particle distribution as a gaussian around
%the true initial value
V = 2; %初始分布的方差
x_P = []; % 粒子
% 用一个高斯分布随机的产生初始的粒子
for i = 1:N
x_P(i) = x + sqrt(V) * randn;
end
z_out = [x^2 / 20 + sqrt(x_R) * randn]; %实际测量值
x_out = [x]; %the actual output vector for measurement values.
x_est = [x]; % time by time output of the particle filters estimate
x_est_out = [x_est]; % the vector of particle filter estimates.
for t = 1:T
x = 0.5*x + 25*x/(1 + x^2) + 8*cos(1.2*(t-1)) + sqrt(x_N)*randn;
z = x^2/20 + sqrt(x_R)*randn;
for i = 1:N
%从先验p(x(k)|x(k-1))中采样
x_P_update(i) = 0.5*x_P(i) + 25*x_P(i)/(1 + x_P(i)^2) + 8*cos(1.2*(t-1)) + sqrt(x_N)*randn;
%计算采样粒子的值,为后面根据似然去计算权重做铺垫
z_update(i) = x_P_update(i)^2/20;
%对每个粒子计算其权重,这里假设量测噪声是高斯分布。所以 w = p(y|x)对应下面的计算公式
P_w(i) = (1/sqrt(2*pi*x_R)) * exp(-(z - z_update(i))^2/(2*x_R));
end
% 归一化.
P_w = P_w./sum(P_w);
%% Resampling
%这里没有用博客里之前说的histc函数,不过目的和效果是一样的
for i = 1 : N
x_P(i) = x_P_update(find(rand <= cumsum(P_w)1)); % 粒子权重大的将多得到后代
end % find( 1) 返回第一个 符合前面条件的数的 下标
%状态估计,重采样以后,每个粒子的权重都变成了1/N
x_est = mean(x_P);
% Save data in arrays for later plotting
x_out = [x_out x];
z_out = [z_out z];
x_est_out = [x_est_out x_est];
end
t = 0:T;
figure(1);
clf
plot(t x_out ‘.-b‘ t x_est_out ‘-.r‘‘linewidth‘3);
set(gca‘FontSize‘12); set(gcf‘Color‘‘White‘);
xlabel(‘time step‘); ylabel(‘flight position‘);
legend(‘True flight position‘ ‘Particle filter estimate‘);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 28 2011-11-26 14:14 particle_filter_demo\particle_filter_demo-master\.gitignore
....... 4278 2011-11-26 14:14 particle_filter_demo\particle_filter_demo-master\draw.py
文件 4788 2014-10-22 23:05 particle_filter_demo\particle_filter_demo-master\draw.pyc
....... 8263 2011-11-26 14:14 particle_filter_demo\particle_filter_demo-master\particle_filter.py
....... 1358 2011-11-26 14:14 particle_filter_demo\particle_filter_demo-master\README
文件 2211 2014-11-15 11:33 particle_filter_demo\Particle_filter_SIR_demo1.m
文件 713 2014-10-24 22:48 particle_filter_demo\PF_Video_EN\calc_log_likelihood.m
文件 1680 2014-10-23 21:09 particle_filter_demo\PF_Video_EN\calc_log_likelihood_mex_handcoded.cpp
文件 328 2014-10-24 20:32 particle_filter_demo\PF_Video_EN\create_particles.m
文件 1052 2014-11-15 11:35 particle_filter_demo\PF_Video_EN\particle_filter_by_saved_movie.m
文件 999 2014-10-23 21:09 particle_filter_demo\PF_Video_EN\particle_filter_by_usb_camera.m
文件 964717 2014-10-23 21:09 particle_filter_demo\PF_Video_EN\Person.wmv
文件 261 2014-10-23 21:09 particle_filter_demo\PF_Video_EN\Readme.txt
文件 322 2014-10-24 21:06 particle_filter_demo\PF_Video_EN\resample_particles.m
文件 153 2014-10-23 21:09 particle_filter_demo\PF_Video_EN\show_particles.m
文件 260 2014-10-23 21:09 particle_filter_demo\PF_Video_EN\show_state_estimated.m
文件 857622 2014-10-23 21:09 particle_filter_demo\PF_Video_EN\Slides_LongVersion.pdf
文件 569154 2014-10-23 21:09 particle_filter_demo\PF_Video_EN\Slides_ShortVersion.pdf
文件 258 2014-10-24 20:35 particle_filter_demo\PF_Video_EN\update_particles.m
目录 0 2014-10-22 23:05 particle_filter_demo\particle_filter_demo-master
目录 0 2014-11-15 11:42 particle_filter_demo\PF_Video_EN
目录 0 2018-11-24 16:31 particle_filter_demo
----------- --------- ---------- ----- ----
2418445 22
- 上一篇:人口模型的处理,二胎影响
- 下一篇:偏微分方程在图形图像处理中的应用matlab代码
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论