%% Moving Standard Deviation of Vector with NaN Elements
% Compute the three-point centered moving standard deviation of a row vector containing two NaN elements.

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

%
% Recalculate the standard deviation, but omit the NaN values. When movstd discards NaN elements, it takes the standard deviation over the remaining elements in the window.

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

% Copyright 2012 The MathWorks, Inc.