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

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

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

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

% Copyright 2012 The MathWorks, Inc.