function demeaned = vdemean(data, profile)
% demeaned = vdemean(data, profile)
% data is Nbins X Ntimes 
% if only one argument, take the mean vertical profiles out; 
%   return Nbins X Ntimes matrix 
% if 'profile' is passed in, take that out instead;

% surely there's one of these somewhere already?
% JH 2001/06/19

if (nargin == 1)
   profile = mstdgap(data');
   profile = profile';
end

if (length(profile) == 1)
   profile = profile*ones(size(data(:,1)));
end

demeaned = data - (profile * ones(size(data(1,:))));


