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

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function h = draw_ellipse_axes(x, c, linespec)
Daniel@0 2 % DRAW_ELLIPSE_AXES(x, c, linespec)
Daniel@0 3 % Draws the major and minor axes of ellipses.
Daniel@0 4 % Ellipses are centered at x with covariance matrix c.
Daniel@0 5 % x is a matrix of columns. c is a positive definite matrix.
Daniel@0 6 % linespec is optional.
Daniel@0 7
Daniel@0 8 [v,e] = eig(c);
Daniel@0 9 v = v*sqrt(e);
Daniel@0 10
Daniel@0 11 h = [];
Daniel@0 12 for j = 1:cols(v)
Daniel@0 13 x1 = repmat(x(1,:),2,1) + repmat([-1;1]*v(1,j),1,cols(x));
Daniel@0 14 x2 = repmat(x(2,:),2,1) + repmat([-1;1]*v(2,j),1,cols(x));
Daniel@0 15 h = [h line(x1,x2)];
Daniel@0 16 end
Daniel@0 17 if nargin > 2
Daniel@0 18 set_linespec(h,linespec);
Daniel@0 19 end