Code help for the diffusion/dispersion coefficient.
Mostrar comentarios más antiguos
B. Consider an array of (n x n) particles initially equally positioned apart from each other by dx=1 and dy=1. Allow these particles to move walk randomly with time in a space much greater than the originally occupied space of (ndx x ndy). Calculate the average square distance between the particles and plot its ratio to the time step . This is the diffusion/dispersion coefficient.
I understand the programming but what iam stuck is with the maths of the problem i understand how to define the initial conditions by this method n=3;
x=1:n
y=1:n
[X,Y]=meshgrid(x,y)
x=reshape(X,1,n^2)
y=reshape(Y,1,n^2)
what is dont understand is how to incorporate the moving particles in time and space, i dont understand this if someone can make it simple i will be able to implement this in programming, just in simple words of what x and y will be used? will be so grateful for the help i dont need the code i just need explanation.
Respuesta aceptada
Más respuestas (1)
Walter Roberson
el 7 de Sept. de 2013
Add an extra dimension to your x and y vectors, representing time step.
x = zeros(n.^2, numtimes);
y = zeros(n.^2, numtimes);
x(:,1) = .... initial vector for x
y(:,1) = .... initial vector for y
then loop, updating x(:,K) from x(:,K-1)
Categorías
Más información sobre Particle & Nuclear Physics en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!