%% Trailing Moving Maximum of Vector
% Compute the three-point trailing moving maximum of a row vector. When there are fewer than three elements in the window at the endpoints, movmax takes the maximum over the number of elements that are available.

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

% Copyright 2012 The MathWorks, Inc.