function E = eccentric(M,e)
%ECCENTRIC	E = eccentric(M,e)
%
%Calculates eccentric anomalies given mean anomaly and eccentricity.
%All angles in radians.    

E=M;

if size(e,1)==1
  e=repmat(e,size(M,1),1);
end

t=floor(3.7*e+3.7);
for i=1:t
	y=M+e.*sin(E)-E;
	dy=e.*cos(E)-1;
	ratio=y./dy;
	E=E-ratio;
end

