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

📄 pf_init.m

📁 % % set some variables in the workspace to control behaviour: % % graphicsMode 0 no graphics, %
💻 M
字号:
%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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -