function main

  close all
  clear all
  clc
  format long G

  % set initial conditions and time interval
  pos1_0 = 1;
  pos2_0 = 1;

  tspan = [0 2];

  % Solve using Runge-Kutta
  [t,pos] = ode45( @RK_derivatives, tspan ,[pos1_0 pos2_0 ]);

  % plot the results
  plot(pos(:,1), pos(:,2),'LineWidth',2 )
  grid on;
  xlabel('\bf\itx \rm\bf(m)')
  ylabel('\bf\ity \rm\bf(m)')
  axis equal               %This forces the axes to be the same scale
    
  %-----------------------------------------------------
  % Function for the derivatives
     function dfdt = RK_derivatives(t,pos)
     %Create an empty column vector that will be filled with the derivatives
     dfdt = zeros(2,1); 
     
     %Calculate the derivatives
     dfdt(1) = pos(1);
     dfdt(2) = 1-0.5*pos(2)*pos(1);
     
   end
end
