% FindTransits

% Plot fStart and fEnd for the next 3000 days
  n = 2000; tStart = 0; tFinal = 3000;
  fStartVal = zeros(n,1); fEndVal = zeros(n,1);
  t = linspace(tStart,tFinal,n)';
  for k=1:n
     fStartVal(k) = fStart(t(k));
     fEndVal(k)   = fEnd(t(k));
  end

  close all
  plot(t,fStartVal,'r',t,fEndVal,'b');
  hold on
  plot([0 tFinal],[0 0],'r')

 % Click in  the approximate transit times...
  title('Click approximate roots')
  [tGuess,z] = ginput(3);
  
 % Bracketing intervals will be plus/minus tau days...
  tau = 30;
  
  clc
  options = optimset('tolx',.0000001);
  for k=1:3
     tStart = fzero(@fStart,[tGuess(k)-tau,tGuess(k)+tau],options);
     tEnd   = fzero(@fEnd,[tGuess(k)-tau,tGuess(k)+tau],options);
     disp([sprintf('Transit %1d : ',k) MakePretty(tEnd-tStart)])
  end

