pf_init.m
来自「% % set some variables in the workspace」· M 代码 · 共 35 行
M
35 行
%PF_INIT Initialize a particle filter
%
% pf = pf_init(span, n, name)
% span = x and y max and min vals, e.g. [-20 20 -20 20]
% n = number of particles, e.g. 800
% name = e.g., 'robot' <-- this argument is optional
%
function pf = pf_init(span, n, name)
pf.n = n;
if nargin >= 3,
pf.name = name;
end
pf.xmin = span(1);
pf.xmax = span(2);
pf.ymin = span(3);
pf.ymax = span(4);
pf.diffuse = 0;
pf.xlate = [0 ; 0];
pf.gpos = [];
pf.dt = 0;
% initialize
for i=1:n,
% s = [x,y] coordinates of each particle:
pf.x(i).s = [rand*(pf.xmax-pf.xmin)+pf.xmin; rand*(pf.ymax-pf.ymin)+pf.ymin];
% pf.x(i).s = [randn(1); randn(1)];
% Prob. of the i'th particle:
pf.x(i).pi = 1/n;
pf.x(i).c = i/n; % cumulative probability
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?