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