Loading the trajectory or trajectories no gaps file into matlab creates two files, probable trajectories and trajectories in the matlab workspace (bottom right - depending on your configuration).
the trajectories file is a 3 dimensional matrix containing XY coordinates (no. frames, no. objects, XY).
you can use this to determine total distance moved by each individual fish by calculating the absolute difference in both X and Y coordinates between each frame.
first you have to define the x axis and y axis, so for example..
x = trajectories( : , : , 1 ) would be the x coordinates and y = trajectories( : , : , 2 ) will be the y coordinates.
then you can calculate the (absolute) difference (absolute because some values may be negative, but for the purposes of totalling the distance travelled you do not want negative values) between each frame along the x and y axis:
differences = abs(diff(x)+diff(y))
this will give you an output array similar to what you started with but containing inter-value differences.
you should then total up these differences:
totaldistance = sum(differences)
that should look something like this:
value1, value2, value3, value4, value5....
...and so on depending on how many objects the software is tracking
you could then plot the values as a histogram for example:
hist(sumdifferences)
so I have been using the example video of the 5 zebrafish to try and write my code. And I have been aiming to get the same kind of information you asked for.
here is my working code so far for total distance:
load trajectories_nogaps
%Reset NaN to 0
trajectories(isnan(trajectories)) = 0;
%XY trajectories
x = trajectories(:,:,1);
y = trajectories(:,:,2);
%Calculate total distance
xydistance = (abs(diff(x))) + (abs(diff(y)));
totaldistance = sum(xydistance);
%Plot data%
bar(totaldistance)
title('Total Distance Moved')
ylabel('distance(pixels)')
xlabel('individual')
axis([0 6 80000 180000])
I'm still pretty new to coding so and MATLAB in particular so there may be an easier way. I'm still working on velocity.
Hope this helps.