%% Moving Minimum of Vector with NaN Elements
% Compute the three-point centered moving minimum of a row vector containing two NaN elements.

A = [4 8 NaN -1 -2 -3 NaN 3 4 5];
M = movmin(A,3)

%
% Recalculate the minimum, but include the NaN values. When taking the minimum over a group of elements containing at least one NaN value, movmin returns NaN.

M = movmin(A,3,'includenan')

% Copyright 2012 The MathWorks, Inc.