Code help for the diffusion/dispersion coefficient.

10 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Image Analyst
Image Analyst il 7 Set 2013
Jerry, you need to specify where the 3 particles start. For example, all along the x axis with y = 0:
x = [0, 1, 2];
y = [0, 0, 0];
That's your starting point and you need to add rows for the new x and y locations for each iteration. For example (untested)
numberOfParticles = 3;
numberOfIterations = 10000;
x = zeros(numberOfIterations, numberOfParticles);
y = zeros(numberOfIterations, numberOfParticles);
x(1, :) = 1 : numberOfParticles;
y(1, :) = zeros(1, numberOfParticles);
for k = 2 : numberOfIterations
x(k, :) = x(k-1, :) + rand(1, numberOfParticles);
and so on. You might want to plot the data either after each iteration or just after the whole experiment of 10,000 iterations has run.
  2 Commenti
Jerry
Jerry il 7 Set 2013
Thanks dear so much you have made alot easier for me iam almost done with it thanks for the help.
Felipe Rios
Felipe Rios il 21 Nov 2018
Hi Jerry; I need to estimate the dispersion coefficient from GPS drifters deployed at sea. Do you happen to have a code that I could use?

Accedi per commentare.

Più risposte (1)

Walter Roberson
Walter Roberson il 7 Set 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)

Categorie

Scopri di più su Programming in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by