function qout = storage_pad(q, pad)

sz = q.nr;
newsz = sz + 2*pad;

if pad >= sz
    error(sprintf('Pad larger than data size... not supported'));
end

qout.nr = newsz;
qout.nc = q.nc;
qout.labels = q.labels;
qout.data = zeros(newsz, q.nc);

% Fill by reflection and inversion
qout.data((pad+1):(q.nr+pad),:) = q.data;
qout.data(1:pad,:) = 2*ones(pad,1)*q.data(1,:)-q.data((pad+1):-1:2,:);
qout.data((q.nr+pad+1):end,:) = 2*ones(pad,1)*q.data(end,:)-q.data((q.nr-1):-1:(q.nr-pad),:);

% Alternative use splines:
npts=3;
qout.data(1:pad,2:end) = spline(q.data(1:npts,1),q.data(1:npts,2:end),qout.data(1:pad,1));
qout.data((q.nr+pad+1):end,2:end) = spline(q.data(end-npts+1:end,1),q.data(end-npts+1:end,2:end),qout.data((q.nr+pad+1):end,1));
