matthiasm@8: function h = draw_circle(x, r, outline_color, fill_color) matthiasm@8: % draw filled circles at centers x with radii r. matthiasm@8: % x is a matrix of columns. r is a row vector. matthiasm@8: matthiasm@8: n = 40; % resolution matthiasm@8: radians = [0:(2*pi)/(n-1):2*pi]; matthiasm@8: unitC = [sin(radians); cos(radians)]; matthiasm@8: matthiasm@8: % extend r if necessary matthiasm@8: if length(r) < cols(x) matthiasm@8: r = [r repmat(r(length(r)), 1, cols(x)-length(r))]; matthiasm@8: end matthiasm@8: matthiasm@8: h = []; matthiasm@8: % hold is needed for fill() matthiasm@8: held = ishold; matthiasm@8: hold on matthiasm@8: for i=1:cols(x) matthiasm@8: y = unitC*r(i) + repmat(x(:, i), 1, n); matthiasm@8: if nargin < 4 matthiasm@8: h = [h line(y(1,:), y(2,:), 'Color', outline_color)]; matthiasm@8: else matthiasm@8: h = [h fill(y(1,:), y(2,:), fill_color, 'EdgeColor', outline_color)]; matthiasm@8: end matthiasm@8: end matthiasm@8: if ~held matthiasm@8: hold off matthiasm@8: end