Moving mean
M = movmean(
返回一个数组的地方A
,k
)k
-pointmeanvalues, where each mean is calculated over a sliding window of lengthk
across neighboring elements ofA
. Whenk
is odd, the window is centered about the element in the current position. Whenk
is even, the window is centered about the current and previous elements. The window size is automatically truncated at the endpoints when there are not enough elements to fill the window. When the window is truncated, the average is taken over only the elements that fill the window.M
都是一样的大小asA
.
IfA
is a vector, thenmovmean
operates along the length of the vector.
IfA
is a multidimensional array, thenmovmean
operates along the first array dimension whose size does not equal 1.
M = movmean(___,
returns the array of moving averages along dimensiondim
)dim
for any of the previous syntaxes. For example, ifA
is a matrix, thenmovmean(A,k,2)
operates along the columns ofA
, computing thek
-element sliding mean for each row.
M = movmean(___,
specifies whether to include or omitnanflag
)NaN
values from the calculation for any of the previous syntaxes.movmean(A,k,'includenan')
includes allNaN
values in the calculation whilemovmean(A,k,'omitnan')
ignores them and computes the mean over fewer points.
M = movmean(___,
specifies additional parameters for the moving average using one or more name-value pair arguments. For example, ifName,Value
)x
is a vector of time values, thenmovmean(A,k,'SamplePoints',x)
computes the moving average relative to the times inx
.