Mercurial > hg > camir-ismir2012
annotate toolboxes/FullBNT-1.0.7/KPMtools/draw_ellipse.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(x, c, outline_color, fill_color) |
Daniel@0 | 2 % DRAW_ELLIPSE(x, c, outline_color, fill_color) |
Daniel@0 | 3 % Draws ellipses at centers x with covariance matrix c. |
Daniel@0 | 4 % x is a matrix of columns. c is a positive definite matrix. |
Daniel@0 | 5 % outline_color and fill_color are optional. |
Daniel@0 | 6 |
Daniel@0 | 7 n = 40; % resolution |
Daniel@0 | 8 radians = [0:(2*pi)/(n-1):2*pi]; |
Daniel@0 | 9 unitC = [sin(radians); cos(radians)]; |
Daniel@0 | 10 r = chol(c)'; |
Daniel@0 | 11 |
Daniel@0 | 12 if nargin < 3 |
Daniel@0 | 13 outline_color = 'g'; |
Daniel@0 | 14 end |
Daniel@0 | 15 |
Daniel@0 | 16 h = []; |
Daniel@0 | 17 for i=1:cols(x) |
Daniel@0 | 18 y = r*unitC + repmat(x(:, i), 1, n); |
Daniel@0 | 19 if nargin < 4 |
Daniel@0 | 20 h = [h line(y(1,:), y(2,:), 'Color', outline_color)]; |
Daniel@0 | 21 else |
Daniel@0 | 22 h = [h fill(y(1,:), y(2,:), fill_color, 'EdgeColor', outline_color)]; |
Daniel@0 | 23 end |
Daniel@0 | 24 end |