I'm trying to generate a model of a random walk within the confines of a cell wall. I have the following code for discrete stepping within the cell:
x(1000)=0;
t(1000)=0;
dt=1;
kB=1.381e-23;
T=310;
R=4.89e-9;
visc=0.007;
friction=6*pi*visc*R;
D=kB*T/friction;
dxdiff=(2*D*dt)^0.5;
Force_applied=1e-15;
for i=(2:1000)
vx=Force_applied/friction;
dx=vx*dt;
x(i)=x(i-1)+dxdiff*(2*(round(rand)-0.5))+dx;
t(i)=(i-1)*dt;
end
Which works, only it's unbound. How would I bind it so that it would stay inside a spherical cell with a given diameter value?