function [ x y ] = anirandomwalk ( xinit, yinit, bias, steps, pausedur ) %UNTITLED Summary of this function goes here % Detailed explanation goes here x(1) = xinit; y(1) = yinit; h = plot(x,y,'XDataSource','x','YDataSource','y'); axis([ -1 1 -1 1 ]*2*sqrt(steps)) ; for k = 1:steps r = rand; if r <= bias(1) x(k+1) = x(k); y(k+1) = y(k)+1; elseif r <= bias(2) x(k+1) = x(k)+1; y(k+1) = y(k); elseif r <= bias(3) x(k+1) = x(k); y(k+1) = y(k)-1; else x(k+1) = x(k)-1; y(k+1) = y(k); end refreshdata(h,'caller'); % Evaluate y in the function workspace drawnow; pause(pausedur); end end