# MSD in Matlab

### From OpenWetWare

Back to documents

Scholars,

In response to several questions:

MSD (Mean Squared Displacement) is a function of time interval. In theory, its value increases linearly with time.

You can compute the MSD for an interval of 0.1 seconds, for example, by simply squaring all of the individual displacements and averaging them (since the sample rate was 10 Hz). The code looks something like: mean(diff(x)^2 + diff(y)^2). For a time interval of 0.2 seconds, the calculation might look something like: mean(diff(x(1:2:end))^2 + diff(y(1:2:end))). And so on...

Obviously, you can compute MSD for all possible values of time interval by putting this calculation inside a loop. For each value of time interval, there will be fewer samples. Therefore, the uncertainty of your estimate will increase as the time interval increases.

Unfortunately, you need to track a decent number of beads in order to narrow the uncertainty at longer intervals, so your results may get a little untidy as the interval increases. It would have been fun to track more beads and do a careful job of the experiment. After all, Jean Baptiste Perrin won the Nobel Prize in 1926 for this exact experiment! Feel free to share some tracks with other scholars. (The lab manual includes a reference to the modern-day replication of Perrin's experiment: http://scitation.aip.org/journals/doc/AJPIAS-ft/vol_74/iss_6/478_1.html.) This paper has an excellent discussion of the topic. (It was just published in 2006 -- basically the same experiment you did.)

--Steve