comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:cc4b1211e677
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