Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
mean-squared displacement

Subject: mean-squared displacement

From: Emma Robertson

Date: 13 Mar, 2012 14:04:12

Message: 1 of 1


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

    %% find the edges of the cell
    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];
     %% This finds the Mean-Squared-Distance for dist1, so I repeat
     %% for dist2,dist3,dist4,dist5
      k=length(dist1)-1; % Number of Interval Time
     for dt = 1:m
        diffxA = dist1(1:k) - dist1((1+dt):(k+dt));
        ACrsquare = diffxA.*diffxA;
        ACmeanrsquare(dt) = mean(ACrsquare);
     RMSD = ACmeanrsquare';
    aa1 = 1:m;
    StepTime = aa1';

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.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us