I have the particle movement data in the following format:
{
{1., 1., 0., 0.},
{1., 2., 0.240727, 0.974106},
{1., 3., 0.0215366, 0.703085},
{1., 4., 0.437541, 1.19085},
{2., 1., 0., 0.},
{2., 2., -2.17808, 0.455328},
{2., 3., -2.97556, -0.668351},
{2., 4., -3.91848, -1.25396},
{3., 1., 0., 0.},
{3., 2., -0.523589, 0.136621},
{3., 3., -1.87956, 0.679403},
{3., 4., -2.36116, 0.749859}
}
The first number is the particle number, second is the frame number in the movie, third is the $x$ position, and the fourth is the $y$-position. So in the above data, the first 4 lists belong to particle 1, the next 4 to particle 2 and the last 4 to particle 3.
I need to calculate the mean square displacement (MSD) $(x_2-x_1)^2 + (y_2-y_1)^2$ for each of the particles separately. I can calculate MSD if I don't have to care about the above data having 3 particles, treat all as the same (but that's not what I want). I need to calculate MSD for each of these particles separately. Basically, somehow I have to tell the program where the the data for particle 1 end and where data for particle 2 starts.
In MATLAB, I have used the find
function to return the location index of the number "1" in the second column of the data and run the loop till that index to calculate MSD for each particle.
I am new to Mathematica and trying to learn it. It's taking me a while to find a answer to this problem. Can anyone help?
Comments
Post a Comment