thresh = 50.0; probs = [0.5 0.52 0.55 0.6]; maxt = 0; for sp = 1:4 p = probs(sp); subplot(2, 2, sp); hold on for k = 1:10 x = randomwalkthresh(p, thresh); if maxt < length(x) maxt = length(x); end plot(x) end hold off title(sprintf('p=%g', p)) xlabel('Time') xlim([0 maxt]) ylabel('Position') end