function d = meandist(V);
% MEANDIST Mean distance between vectors.
% MEANDIST(V) calculates the mean distance between all
% all vectors in the matrix of row vectors.

%% Sum distance between vectors
sz = size(V);
total = 0;
vlast = V(1,:);
for i = 2:sz(1)
    vi = V(i,:);
    total = total + norm(vi - vlast);
    vlast = vi;
end

%% Average by number of gaps
d = total / (sz(1) - 1);