  function P1Sol()
% Exponential fitting of supernova data

  close all
  [t,LVals] = LuminData;
  tVals = linspace(t(1),t(length(t)));
  
  % If L(t) = C*exp(-t/alfa), then L(tau1)/L(tau2) = exp((tau2-tau1)/alfa)
  % so alfa = (tau2-tau1)/log(L(tau1)/L(tau2)).
  % Playing with this we estimate alfa values in the vicinity of 5 and
  % 60...
  
% Treat as a 2-parameter fitting problem, use backslash...
  figure
  xStar = lsqnonlin(@(x) F2(x,t,LVals),[5 60]);
  alfa1 = xStar(1); alfa2 = xStar(2); 
  c = [exp(-t/alfa1) exp(-t/alfa2)]\LVals;
  plot(t,LVals,'o',tVals,c(1)*exp(-tVals/alfa1)+c(2)*exp(-tVals/alfa2))
  title(sprintf('c1 = %10.5f    c2 = %10.5f    alfa1 = %10.5f    alfa2 = %10.5f',c,alfa1,alfa2))
  
  function z = F2(x,t,LVals)
  alfa1 = x(1); alfa2 = x(2);
  M = [exp(-t/alfa1) exp(-t/alfa2)];
  c = M\LVals;
  z = M*c - LVals;
  
  
  
  
  