function henonorb(y,y1,d,iter,e,j) %y=yposition y1=velocity,d=time step %iter=iterations, e=energy, j=1 live motion %e.g. e=1/12; e=1/8; or e=1/6; %p=.205; q=.265; r=.05; s=200; %henonorb(p,q,r,100*s,e,0); clf hold on if (j==1) set(gca,'nextplot','replacechildren'); end x=0; x1=real(sqrt(2*e-y1*y1-y*y+2*y*y*y/3)); for i=1:iter xh=x; x2=-x - 2 * x * y; y2=-y - x * x + y * y; x1=x1 + x2 * d; y1=y1 + y2 * d; xx=x + x1 * d; yy=y + y1 * d; line([x xx],[y yy]); x=xx; y=yy; if (j==1) F(i) = getframe; end end %movie(F,1); hold off