% nbp.m
%
% Numerically integrate N particles under the action of their mutual gravity
%
% This code requires the following functions to run:
%   - nbpRKN1210.m
%   - rkn1210.m (written by Rody Oldenhuis, available on MATLAB File Exchange)
%
% Syntax for calling nbpRKN1210 code:
%
% vals = nbpRKN1210(mass, pos, vel, [tBegin tEnd], flags);
%
% MATLAB-Monkey.com   10/6/2013

clc
clear

% particle 1
m(1) = 1;
pos(1) = -1;
pos(2) = -1;
vel(1) = .6;
vel(2) = 0;

% particle 2
m(2) = 2;
pos(3) = 1;
pos(4) = 1;
vel(3) = -.3;
vel(4) = 0;

% particle 3
m(3) = .1;
pos(5) = 0;
pos(6) = 0;
vel(5) = .7;
vel(6) = .1;

times = [0 100];

%%%%%%%%%%  Set plotting flags for integrator
animateFlag = true;
trailFlag = true;
flags = [animateFlag, trailFlag];  % plotting flags


%%%%%%%%%%  Integrate 

vals = nbpRKN1210(m, pos, vel, times, flags);

% extract time, positions and velocities of test particle(s)
% t = vals(:,1);
% pos = vals(:,2:2*NP+1);
% vel = vals(:,2*NP+2:4*NP+1);



