counter = 1; posnx1 = 0; posny1 = 0; posnx2 = 0; posny2 = 0; steps = 30; threshx = 0.5; threshy = 0.5; for i = 1:steps plot(posnx1,posny1,'o',posnx2,posny2,'ro') set(gca,'XLim',[-10 10]) set(gca,'YLim',[-10 10]) F(i) = getframe; tmp = rand(2,2); if tmp(1,1) > threshx posnx1 = posnx1 + 1; else posnx1 = posnx1 - 1; end if tmp(2,1) > threshy posny1 = posny1 + 1; else posny1 = posny1 - 1; end if tmp(1,2) > threshx posnx2 = posnx2 + 1; else posnx2 = posnx2 - 1; end if tmp(2,2) > threshy posny2 = posny2 + 1; else posny2 = posny2 - 1; end end