Rev | Line | |
---|
[37] | 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 |
---|
Note: See
TracBrowser
for help on using the repository browser.