資源簡介
MATLAB,粒子濾波,Particle Filter,Sampling Importance Resampling Filter,跟蹤,預測,
代碼片段和文件信息
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;??
????????%計算采
- 上一篇:女士品茶.mobi
- 下一篇:三維三次樣條插值計算三坐標
評論
共有 條評論