% FindTransitsX

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

  close all
  plot(t,fStartXVal,'r',t,fEndXVal,'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(@fStartX,[tGuess(k)-tau,tGuess(k)+tau],options);
     tEnd   = fzero(@fEndX,[tGuess(k)-tau,tGuess(k)+tau],options);
     disp([sprintf('Transit %1d : ',k) MakePretty(tEnd-tStart)])
  end

