www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/MovingMedianOfVectorWithNaNElementsExample.m

    %% Moving Median of Vector with |NaN| Elements
% Compute the three-point centered moving median of a row
% vector containing |NaN| elements.
A = [4 8 NaN -1 -2 -3 NaN 3 4 5];
M = movmedian(A,3)

%%
% Recalculate the median, but omit the |NaN| values.  When
% |movmedian| discards |NaN| elements, it takes the median over
% the remaining elements in the window.
M = movmedian(A,3,'omitnan')