function [p] = calcMSD2(path, L, min_dt, max_dt, dt)

msd = [];
path = path(:,1:2)*0.075;
dt = dt*0.001;

tvec = dt:dt:100*dt;

path = path(1:L,:);

for i=min_dt:max_dt
    msd(i) = mean(sum((path(i+1:end,:)-path(1:end-i,:)).^2,2));
end

%p = tvec(min_dt:max_dt)'\msd(min_dt:max_dt)';

p = polyfit(tvec(min_dt:max_dt),msd(min_dt:max_dt),1); p = p(1);

