function threebody_script(x3,y3,T,r) % Plot script for the Three-body problem % Input values: T,x3,y3 % T = itteration time % x3 = Initial x-coordinate for mass 3 % y3 = Initial y-coordinate for mass 3 % r = relative tolerance (1e-3 defaut) % Mass 1 Initial Position: (1,0) % Mass 1 Initial Velocity: <0,-1> % Mass 2 Initial Position: (-1,0) % Mass 2 Initial Velocity: <0,1> % Mass 3 Initial Velocity: <-1,0> % Options to set absolute and relative tolerance levels % options default: 'AbsTol',1e-6,'RelTol',1e-3 options = odeset('AbsTol',1e-06,'RelTol',r); % uncomment for Runge Kutta 4-5 method without options [t,x]=ode45('threebody',[0:0.01:T],[-1,0,1,0,x3,-1,0,-1,0,1,y3,0],options); % terminal printing ... figure; % close; plot(x(:,5),x(:,11),x(:,1),x(:,7),x(:,3),x(:,9)); axis ([-1.5 1.5 -1.5 1.5]); %Apply Lables and Title xlabel('X'); ylabel('Y'); title(['3-Body System: ','mass1_0=(-1,0) ; mass2_0=(1,0) ; mass3_0=(', num2str(x3),',',num2str(y3),')',' ; T=',num2str(T),' tol=',num2str(r)]); % print plot in eps format print -depsc orbit.eps % print as jpeg name = ['threebody_x3=', num2str(x3),'_y3=',num2str(y3),'_T=',num2str(T),'_tol=',num2str(r),'.jpg']; print ('-djpeg(100)', name)