wolffd@0: function h = draw_circle(x, r, outline_color, fill_color) wolffd@0: % draw filled circles at centers x with radii r. wolffd@0: % x is a matrix of columns. r is a row vector. 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: wolffd@0: % extend r if necessary wolffd@0: if length(r) < cols(x) wolffd@0: r = [r repmat(r(length(r)), 1, cols(x)-length(r))]; wolffd@0: end wolffd@0: wolffd@0: h = []; wolffd@0: % hold is needed for fill() wolffd@0: held = ishold; wolffd@0: hold on wolffd@0: for i=1:cols(x) wolffd@0: y = unitC*r(i) + 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 wolffd@0: if ~held wolffd@0: hold off wolffd@0: end