|
Hi,
I have an NxN zero lattice which is initialised with 5x5 non-zero pixels (which represents a biological cell) at the top of the lattice. I run my stochastic model and inspect how far the cell had moved in "m" Monte-Carlo time Steps (MCS). I do this because I want to find the diffusion co-efficient of the simulated cell and compare it with real data, which in turn will allow me to calculate what "m" MCS corresponds to in real time.
I wrote this simple piece of code and wanted to compare my Mean-Squared-Distance (MSD) with an already established result, but seem to get very small MSD compared to theirs. Can anyone please have a look and point out if there are any mistakes (I have already done that myself but didn't seem to find anything wrong)?
A bit about the code: I run the model until t=3000, and store the distances in a vector, then calculate the MSD for each time interval
E.g. here's a skeleton of the code
for t=1:3000 % Monte-carlo time steps
for ks=1:10
do stuff with the cell
^^^^^^^^^^^^^^^^^^
end
%% find the edges of the cell
[row,col]=find(lattice>0);
minxe=min(col);
maxxe=max(col);
minye=min(row);
maxye=max(row);
vert=abs(maxyi-maxye)+1; % vertical distance
horiz=abs(maxxi-minxe)+1; %horizontal distance
diagn=sqrt(vert^2+horiz^2); % diagonal distance
if t>=0 & t<600
dist1=[dist1 diagn];
elseif(t>=600 & t<1200)
dist2=[dist2 diagn];
elseif(t>=1200 & t<1800)
dist3=[dist3 diagn];
elseif(t>=1800 & t<2400)
dist4=[dist4 diagn];
elseif(t>=2400 & t<3000)
dist5=[dist5 diagn];
end
%% This finds the Mean-Squared-Distance for dist1, so I repeat
%% for dist2,dist3,dist4,dist5
k=length(dist1)-1; % Number of Interval Time
m=1;
for dt = 1:m
diffxA = dist1(1:k) - dist1((1+dt):(k+dt));
ACrsquare = diffxA.*diffxA;
ACmeanrsquare(dt) = mean(ACrsquare);
end
RMSD = ACmeanrsquare';
aa1 = 1:m;
StepTime = aa1';
end
The end result should be a plot with time steps on the x-axis and <s^2> on the y-axis.
Many thanks in advance. Please let me know if anything is unclear and I will try to explain.
|