% "Input vars" N = 30; M = 5; % Random steps dx = ones(N,M); dy = 2*round(rand(N,M))-1; % Make our path vectors x = cumsum(dx); y = cumsum(dy); % Set up the figure figure(1), clf, hold on style = {'k','g','r','b','c'}; % Make the plot of the paths for i=1:M plot(x(:,i),y(:,i),style{mod(i,length(style))+1}) end % Make the endpoints black dots. plot(x(N,:),y(N,:),'k.','MarkerSize',30)