function timeExpanded = expandTimeForTimeseries(time, fundamentalSampleTime, fundamentalSampleTimeExpand)
%

%   Copyright 2008-2009 The MathWorks, Inc.

    if nargin<3
        fundamentalSampleTimeExpand = fundamentalSampleTime;
    end
    % We use round instead of floor because we want to know the nearest
    % integer. The reason being (time(end)-time(1))/fundamentalSampleTime
    % should always result in a whole number 'x'. May be due to double
    % precision we may see x + delta or x - delta, in which case floor may
    % give wrong answer.  For e.g., floor (16.2/0.1) should result in 162,
    % but due to double precison it will result in 161. Whereas, round 
    % would always result in whole number we are expecting as delta will be
    % usually be much less than 0.5.
    
    numberSteps = round((time(end)-time(1))/fundamentalSampleTime) + 1;
    timeExpanded = (0:(numberSteps-1))*fundamentalSampleTimeExpand;
end