function varxV = GrowVariance(xV,dtV)
% varxV = GrowVariance(xV,dtV)
% GrowVariance computes the variance growth as a function of time segment.
% INPUT 
% - xV      : the time series
% - dtV     : the array of increasing time segment lengths.
% OUTPUT 
% - varxV   : the mean variance for the given segment lengths.

n = length(xV);
ndt = length(dtV);
varxV = NaN*ones(ndt,1);
for i=1:ndt
    w = dtV(i);
    nseg=floor(n/w);  % number of segments of the given length
    xM=reshape(xV(1:w*nseg),w,nseg); % a segment at each column
    varxV(i) = mean(var(xM)); % variance for each segment and then mean of variances
end
