function res = fixangles(angles)
%% res= fixangles(angles) eliminates the 2*pi jumps in a vector of angle values

n = length(angles);
res = angles;
k = 0;
da = diff(angles);
for i = 1:n-1;
  k -= round(da(i)/(2*pi));
  res(i+1) += k*2*pi;
end

