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

A = [2 1 NaN -1 -2 -3 NaN 3 4 1];
M = movprod(A,3)

%
% Recalculate the product, but omit the NaN values. When movprod discards NaN elements, it takes the product over the remaining elements in the window.

M = movprod(A,3,'omitnan')

% Copyright 2012 The MathWorks, Inc.