필터 지우기
필터 지우기

Code help for the diffusion/dispersion coefficient.

조회 수: 4 (최근 30일)
Jerry
Jerry 2013년 9월 7일
댓글: Felipe Rios 2018년 11월 21일
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에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by