## the function that takes in the initial positions
## of random walkers and the number of steps as
## an argument and returns the final positions
## in 2D. The figure of the walkers after the comple-
## tion of the walk also plotted.
function f=diffusion(Nsteps)
f=[];
Nwalkers=9;
for i=1:Nsteps ## The loop through the number
## of steps each in walk.
p=initial_positions(Nwalkers); ## Initial squared location of all of the
## walkers at all steps.
for m=1:Nwalkers ## The loop through the desired
## number of walkers.
r=rand_disc_rev(N); ## Calling the rw generator
## function which will give column vector
f=[f;p+r] ## of each elements are either 1 or -1.
## Total displacement whose
## elements stems from the vector r.
endfor
f
endfor
plot(f(:,1),f(:,2),'r*;Dif;')
endfunction
## of random walkers and the number of steps as
## an argument and returns the final positions
## in 2D. The figure of the walkers after the comple-
## tion of the walk also plotted.
function f=diffusion(Nsteps)
f=[];
Nwalkers=9;
for i=1:Nsteps ## The loop through the number
## of steps each in walk.
p=initial_positions(Nwalkers); ## Initial squared location of all of the
## walkers at all steps.
for m=1:Nwalkers ## The loop through the desired
## number of walkers.
r=rand_disc_rev(N); ## Calling the rw generator
## function which will give column vector
f=[f;p+r] ## of each elements are either 1 or -1.
## Total displacement whose
## elements stems from the vector r.
endfor
f
endfor
plot(f(:,1),f(:,2),'r*;Dif;')
endfunction
Comments
Post a Comment