Mercurial > hg > camir-ismir2012
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toolboxes/FullBNT-1.0.7/KPMtools/draw_ellipse_axes.m Fri Aug 19 13:07:06 2016 +0200 @@ -0,0 +1,19 @@ +function h = draw_ellipse_axes(x, c, linespec) +% DRAW_ELLIPSE_AXES(x, c, linespec) +% Draws the major and minor axes of ellipses. +% Ellipses are centered at x with covariance matrix c. +% x is a matrix of columns. c is a positive definite matrix. +% linespec is optional. + +[v,e] = eig(c); +v = v*sqrt(e); + +h = []; +for j = 1:cols(v) + x1 = repmat(x(1,:),2,1) + repmat([-1;1]*v(1,j),1,cols(x)); + x2 = repmat(x(2,:),2,1) + repmat([-1;1]*v(2,j),1,cols(x)); + h = [h line(x1,x2)]; +end +if nargin > 2 + set_linespec(h,linespec); +end