function a = tbl_ext(aa);

% Extend the limits of an array before using it in the table1 function.
% That is, two fake rows are added, one at the start and
% one at the end.  The time span of the array is tripled.
% The new first row has all other values the same as the
% old first row, and similarly for the last row.  This
% means that when the array is used for interpolations,
% times falling a bit outside the original range take on
% the values of the beginning or end of the array, as
% appropriate.  This prevents annoying error messages and
% routine failures when an array does not quite span the
% range of times to be interpolated.

[nr, nc] = size(aa);

a = [aa(1,:) ; aa ; aa(nr,:)];
dt = aa(nr,1)-aa(1,1);
a(nr+2,1) = aa(nr,1) + dt;
a(1,1) = aa(1,1) - dt;
