% circlewalk.m
% C Bishop 
% approximate a 2-dimensional Brownian motion taking same 
% sized steps in random directions
close all;
pt=0;
circle=exp(2*pi*i*[0:.01:1]);
dot=.1*circle;
figure; hold on; axis equal; axis off;
a=5;
plot([-a,a,a,-a],[-a,-a,a,a],'w');
patch(real(pt+dot),imag(pt+dot),'k');
for k=1:100
    plot(pt+circle,'r');
    old_pt=pt;
    pt=pt+exp(2*pi*i*rand);
    patch(real(pt+dot),imag(pt+dot),'k');
    plot([old_pt,pt],'k','LineWidth',2);
    xi=input('keep plotting?  1= yes, 2= no.');
      if xi==2
          break;
      end  % if
end % for k
