%
%  2-D random walk code
%

nw =  10;  				% number of walkers
ns = 20;				% number of steps taken

%
%  random walk (unit step in random direction)
%
pw = zeros(nw,1);			% initial position of walkers

for j1 = 1:ns
   angles = 2*pi*rand(nw,1);		        % vector of nw random angles
   pw = [pw  (pw(:,end) + exp(i*angles))];  % unit step in angle direction
end 

hold on
for j1 = 1:nw
   plot(pw(j1,:),'b:')
   plot(pw(j1,end),'ro')
end

axis([-10 10 -10 10])