Optional std deviation scaling (developed with Frank)

release/4.3a0
Alex Cunningham 2013-10-29 14:34:41 +00:00
parent 6c1f851d51
commit d1ff62d640
1 changed files with 4 additions and 3 deletions

View File

@ -1,16 +1,17 @@
function covarianceEllipse(x,P,color) function covarianceEllipse(x,P,color, k)
% covarianceEllipse plots a Gaussian as an uncertainty ellipse % covarianceEllipse plots a Gaussian as an uncertainty ellipse
% Based on Maybeck Vol 1, page 366 % Based on Maybeck Vol 1, page 366
% k=2.296 corresponds to 1 std, 68.26% of all probability % k=2.296 corresponds to 1 std, 68.26% of all probability
% k=11.82 corresponds to 3 std, 99.74% of all probability % k=11.82 corresponds to 3 std, 99.74% of all probability
% %
% covarianceEllipse(x,P,color) % covarianceEllipse(x,P,color,k)
% it is assumed x and y are the first two components of state x % it is assumed x and y are the first two components of state x
% k is scaling for std deviations, defaults to 1 std
[e,s] = eig(P(1:2,1:2)); [e,s] = eig(P(1:2,1:2));
s1 = s(1,1); s1 = s(1,1);
s2 = s(2,2); s2 = s(2,2);
k = 2.296; if nargin<4, k = 2.296; end;
[ex,ey] = ellipse( sqrt(s1*k)*e(:,1), sqrt(s2*k)*e(:,2), x(1:2) ); [ex,ey] = ellipse( sqrt(s1*k)*e(:,1), sqrt(s2*k)*e(:,2), x(1:2) );
line(ex,ey,'color',color); line(ex,ey,'color',color);