lundi 25 avril 2016

random walker in 2d in MATLAB for long times

I tried to simulate a simple random walker in 2D Iin MATLAB. The walker is confined between 2 walls in y=0 and y=5.My problem is that, the path of particle is very asymmetric in x direction. this is the code:

clc; clear;  y(1) = 0; x(1) =0 ; for i = 2:2000000 x(i) = x(i-1)+randn(1,1); y(i) = y(i-1) + randn(1,1);  if(y(i) <= 0 || y(i)>5) x(i) = x(i-1);  y(i)= y(i-1);  end  end  plot(x,y)




Aucun commentaire:

Enregistrer un commentaire