% Use run x9827215
% do lag est

lagest; % generates plot

n = length(zlag);

% bnd_deriv =  ./ (tlag(1:2:(n-3), :) - tlag(3:2:(n-1), :));
a = (tlag(2:2:(n-2),:) - tlag(1:2:(n-3), :)) ./ (tlag(1:2:(n-3), :) - tlag(3:2:(n-1), :));
b = 1 - a;
z_up_interp = a.*zlag(1:2:(n-3), :) + b.*zlag(3:2:(n-1), :);

z_err = zlag(2:2:(n-2),:) - z_up_interp;


figure;
plot(dzdtlag(2:2:(n-2),:), z_err, '+')
xlabel('AUV closure speed (m/s)');


