movvar
R2026bMoving variance
Syntax
Description
returns the local V = movvar(A,k)k-point variance values, where each variance is calculated over a sliding window
of length k across neighboring elements in A.
When k is odd, the window is centered about the element in the
current position. When k 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 variance is calculated over only the elements that fill the window.
V is the same size as A.
If
Ais a vector, thenmovvaroperates along the length of the vectorA.If
Ais a multidimensional array, thenmovvaroperates along the first dimension ofAwhose size is greater than 1.If
Ais a table or timetable, thenmovvaroperates along the variables ofA. (since R2025a)
specifies the dimension of V = movvar(___,w,dim)A to operate along for any of the
previous syntaxes. Always specify the weight w from the previous
syntax when specifying dim. For example, if A
is a matrix, then movvar(A,k,0,2) operates along the columns of
A, computing the k-element sliding
variance for each row. The normalization factor is the default,
k-1.
specifies additional options for the variance using one or more name-value
arguments. For example, if V = movvar(___,Name=Value)x is a vector of time values, then
movvar(A,k,SamplePoints=x) computes the moving variance
relative to the times in x.

![movvar(A,[2 1]) computation. The elements in the sample window are 4, 1, 3, and 5, so the resulting local variance is 2.92.](movvar_windowing.png)

