% est_pairwise_cont:   continuation after crash

% set l1 to last valid file (go one back just to be sure in case crash
%                            was during write of last .mat file)
l1=12    % begin frame

dis('last valid file set to %03d',l1);
l2=67  % end frame (there are 68 frames numbered 0 to 67)

dis('loading parameters_pairwisem_3_3_%03d',l1)
eval(sprintf('load parameters_pairwisem_3_3_%03g',l1))

for l = l1+1:l2   % pairwise of frames l1..l2-1 with l1+1..l2
%e.g. if l1=73, then it would be ``for l = 74:l2'' to continue after crash
  A = eval(sprintf('loadframe(%d)',l-1));
  figure(1);  % keep from running out of memory (limit fig use)
  B = eval(sprintf('loadframe(%d)',l));
  disp(sprintf('--- estimating translation frame 0 to %d',l))
  p_trans=est_trans_fft2(A,B); % now takes B to A
  p_now=est_pchirp2m(A,B,3,3,p_trans,1);
  p=[p;p_now]; % concatenate each time
  mse=mean2nan(abs(A-pchirp2(p_now,B)));
  err_history=[err_history;mse];
  s = sprintf('save parameters_pairwisem_3_3_%03d p err_history',l);
  disp(s)
  eval(s)
end%for

