Code help for the diffusion/dispersion coefficient.

10 次查看(过去 30 天)
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.

采纳的回答

Image Analyst
Image Analyst 2013-9-7
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 个评论
Jerry
Jerry 2013-9-7
Thanks dear so much you have made alot easier for me iam almost done with it thanks for the help.
Felipe Rios
Felipe Rios 2018-11-21
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?

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2013-9-7
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)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by