%% Vector with NaN Values
% Create a vector containing NaN values and compute the cumulative minima. By default, cummin ignores NaN values.

A = [3 5 NaN 9 0 NaN];
M = cummin(A)

%
% If you include NaN values in the calculation, then the cumulative minimum becomes NaN as soon as the first NaN value in A is encountered.

M = cummin(A,'includenan')

% Copyright 2012 The MathWorks, Inc.