annotate _FullBNT/KPMtools/draw_ellipse.m @ 9:4ea6619cb3f5 tip

removed log files
author matthiasm
date Fri, 11 Apr 2014 15:55:11 +0100
parents b5b38998ef3b
children
rev   line source
matthiasm@8 1 function h = draw_ellipse(x, c, outline_color, fill_color)
matthiasm@8 2 % DRAW_ELLIPSE(x, c, outline_color, fill_color)
matthiasm@8 3 % Draws ellipses at centers x with covariance matrix c.
matthiasm@8 4 % x is a matrix of columns. c is a positive definite matrix.
matthiasm@8 5 % outline_color and fill_color are optional.
matthiasm@8 6
matthiasm@8 7 n = 40; % resolution
matthiasm@8 8 radians = [0:(2*pi)/(n-1):2*pi];
matthiasm@8 9 unitC = [sin(radians); cos(radians)];
matthiasm@8 10 r = chol(c)';
matthiasm@8 11
matthiasm@8 12 if nargin < 3
matthiasm@8 13 outline_color = 'g';
matthiasm@8 14 end
matthiasm@8 15
matthiasm@8 16 h = [];
matthiasm@8 17 for i=1:cols(x)
matthiasm@8 18 y = r*unitC + repmat(x(:, i), 1, n);
matthiasm@8 19 if nargin < 4
matthiasm@8 20 h = [h line(y(1,:), y(2,:), 'Color', outline_color)];
matthiasm@8 21 else
matthiasm@8 22 h = [h fill(y(1,:), y(2,:), fill_color, 'EdgeColor', outline_color)];
matthiasm@8 23 end
matthiasm@8 24 end