Newer
Older
abgabensammlungSS15 / mr / ub9 / loc_jp / ukf_sigma_points.m
@Jan-Peter Hohloch Jan-Peter Hohloch on 27 Jun 2015 729 bytes MR: begin 1st exercise - not fully working yet
function [ S w] = ukf_sigma_points( mu, cov, w0 )
%UKF_SIGMA_POINTS Compute sigma points from mean and covariance matrix.

% Use default value for w0 if it is not provided as a parameter:
if nargin < 3
    w0 = 1/3;
end

nx = size(mu,1); % Dimension (3 for 2D localization)

n = 2*nx + 1;    % n sigma points

% Store sigma points in (nx x n) matrix
% Sigma point i is S(:,i)
S = zeros(nx, n);

% Store weights in (n x 1) matrix:
% Weight of sigma point i is w(i);
w = zeros(n,1);

% YOUR CODE STARTS HERE
w(1)=w0;
S(:,1)=mu;

offset=sqrt(nx/(1-w0))*sqrtm(cov);
weight=(1-w0)/(2*nx);

for i=2:nx+1
    S(:,i)=mu+offset(:,i-1);
    w(i)=weight;
    S(:,i+nx)=mu-offset(:,i-1);
    w(i+nx)=weight;
end


% YOR CODE ENDS HERE

end