annotate toolboxes/FullBNT-1.0.7/KPMtools/draw_ellipse_axes.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function h = draw_ellipse_axes(x, c, linespec)
wolffd@0 2 % DRAW_ELLIPSE_AXES(x, c, linespec)
wolffd@0 3 % Draws the major and minor axes of ellipses.
wolffd@0 4 % Ellipses are centered at x with covariance matrix c.
wolffd@0 5 % x is a matrix of columns. c is a positive definite matrix.
wolffd@0 6 % linespec is optional.
wolffd@0 7
wolffd@0 8 [v,e] = eig(c);
wolffd@0 9 v = v*sqrt(e);
wolffd@0 10
wolffd@0 11 h = [];
wolffd@0 12 for j = 1:cols(v)
wolffd@0 13 x1 = repmat(x(1,:),2,1) + repmat([-1;1]*v(1,j),1,cols(x));
wolffd@0 14 x2 = repmat(x(2,:),2,1) + repmat([-1;1]*v(2,j),1,cols(x));
wolffd@0 15 h = [h line(x1,x2)];
wolffd@0 16 end
wolffd@0 17 if nargin > 2
wolffd@0 18 set_linespec(h,linespec);
wolffd@0 19 end