%
%
%
clear all

t=linspace(0,20,100)

h=sin(t)*360
h1=mod(h,360)

L=size(t,2)

h2(1) = h(1);
for i=2:L
  h2(i) = h(i);
  while( (h2(i)-h2(i-1))>90)
    h2(i)=h2(i)-360;
  end
  while( (h2(i)-h2(i-1))<-90)
    h2(i)=h2(i)+360;
  end
end

hold on
plot(t,h,'.')
plot(t,h1)
plot(t,h2)

