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