wolffd@0: function h = draw_ellipse(x, c, outline_color, fill_color) wolffd@0: % DRAW_ELLIPSE(x, c, outline_color, fill_color) wolffd@0: % Draws ellipses at centers x with covariance matrix c. wolffd@0: % x is a matrix of columns. c is a positive definite matrix. wolffd@0: % outline_color and fill_color are optional. wolffd@0: wolffd@0: n = 40; % resolution wolffd@0: radians = [0:(2*pi)/(n-1):2*pi]; wolffd@0: unitC = [sin(radians); cos(radians)]; wolffd@0: r = chol(c)'; wolffd@0: wolffd@0: if nargin < 3 wolffd@0: outline_color = 'g'; wolffd@0: end wolffd@0: wolffd@0: h = []; wolffd@0: for i=1:cols(x) wolffd@0: y = r*unitC + repmat(x(:, i), 1, n); wolffd@0: if nargin < 4 wolffd@0: h = [h line(y(1,:), y(2,:), 'Color', outline_color)]; wolffd@0: else wolffd@0: h = [h fill(y(1,:), y(2,:), fill_color, 'EdgeColor', outline_color)]; wolffd@0: end wolffd@0: end