movstd
移动标准偏差
Syntax
Description
m = movstd(
returns an array of localA
,k
)k
-观点standard deviation值。每个标准偏差都是通过长度的滑动窗口计算的k
跨越相邻元素A
。什么时候k
很奇怪,窗口以当前位置的元素为中心。什么时候k
即使是,窗口都集中在当前和以前的元素上。当没有足够的元素填充窗口时,窗口大小会在端点自动截断。当窗口被截断时,标准偏差仅在填充窗口的元素上进行。M
is the same size asA
。
如果
A
is a vector, thenmovstd
沿矢量的长度运行。如果
A
is a multidimensional array, thenmovstd
沿着大小不等于1的第一个数组维度操作。
m = movstd(___,
specifies a normalization factor for any of the previous syntaxes. Whenw
)w = 0
(默认),M
is normalized byk-1
for window lengthk
。什么时候w = 1
,M
is normalized byk
。
m = movstd(___,
specifies whether to include or omitNanflag
)NaN
values from the calculation for any of the previous syntaxes.movstd(a,k,'includeenan')
includes allNaN
values in the calculation whilemovstd(A,k,'omitnan')
ignores them and computes the standard deviation over fewer points.
Examples
Centered Moving Standard Deviation of Vector
计算行矢量的三点中心运动标准偏差。当端点处的窗口中的元素少于三个元素时,请对可用元素进行标准偏差。
a = [4 8 6 -1 -1 -2 -3 -1 3 4 5];m = movstd(a,3)
M =1×102.8284 2.0000 4.7258 4.3589 1.0000 1.0000 3.0551 2.6458 1.0000 0.7071
向量的尾随移动标准偏差
计算行矢量的三点尾随运动标准偏差。当端点处的窗口中的元素少于三个元素时,请对可用元素进行标准偏差。
a = [4 8 6 -1 -1 -2 -3 -1 3 4 5];m = movstd(A,[2 0])
M =1×100 2.8284 2.0000 4.7258 4.3589 1.0000 1.0000 3.0551 2.6458 1.0000
Specify Normalization for Moving Standard Deviation
计算行矢量的三点中心运动标准偏差,并按照窗口中的元素数量将每个标准偏差归一化。
a = [4 8 6 -1 -1 -2 -3 -1 3 4 5];m = movstd(a,3,1)
M =1×102.0000 1.6330 3.8586 3.5590 0.8165 0.8165 2.4944 2.1602 0.8165 0.5000
Moving Standard Deviation of Matrix
计算矩阵每一行的三点中心运动标准偏差。窗口从第一行开始,水平滑到行的末端,然后移至第二行,依此类推。维度参数是两个,它将窗口滑过A
。Always specify the normalization factor when specifying the dimension.
A = [4 8 6; -1 -2 -3; -1 3 4]; M = movstd(A,3,0,2)
M =3×32.8284 2.0000 1.4142 0.7071 1.0000 0.7071 2.8284 2.6458 0.7071
Moving Standard Deviation of Vector withNaN
元素
Compute the three-point centered moving standard deviation of a row vector containing twoNaN
元素。
A = [4 8 NaN -1 -2 -3 NaN 3 4 5]; M = movstd(A,3)
M =1×102.8284 NaN NaN NaN 1.0000 NaN NaN NaN 1.0000 0.7071
重新计算标准偏差,但省略了NaN
值。什么时候movstd
discardsNaN
elements, it takes the standard deviation over the remaining elements in the window.
m = movstd(a,3,'omitnan')
M =1×102.8284 2.8284 6.3640 0.7071 1.0000 0.7071 4.2426 0.7071 1.0000 0.7071
移动标准偏差的样本点
计算数据中的3小时中心移动标准偏差A
根据时间向量t
。
= [4 8 6 1 2 3]; k = hours(3); t = datetime(2016,1,1,0,0,0) + hours(0:5)
t =1x6 datetime arrayColumns 1 through 3 01-Jan-2016 00:00:00 01-Jan-2016 01:00:00 01-Jan-2016 02:00:00 Columns 4 through 6 01-Jan-2016 03:00:00 01-Jan-2016 04:00:00 01-Jan-2016 05:00:00
m = movstd(A,k,'SamplePoints',t)
M =1×62.8284 2.0000 4.7258 4.3589 1.0000 0.7071
仅返回全窗口标准偏差
计算行矢量的三点中心运动标准偏差,但丢弃了从输出中使用少于三个点的任何计算。换句话说,仅返回从完整的三元素窗口计算的标准偏差,丢弃端点计算。
a = [4 8 6 -1 -1 -2 -3 -1 3 4 5];m = movstd(a,3,'端点','discard')
M =1×82.0000 4.7258 4.3589 1.0000 1.0000 3.0551 2.6458 1.0000
Input Arguments
A
—Input array
向量|matrix|multidimensional array
Input array, specified as a vector, matrix, or multidimensional array.
Data Types:单身的
|double
|logical
k
—Window length
数字或持续时间标量
Window length, specified as a numeric or duration scalar. Whenk
is a positive integer scalar, the centered standard deviation includes the element in the current position plus surrounding neighbors. For example, a three-point standard deviation defined by a window of length three results in the following calculation for a vectorA
:
Data Types:单身的
|double
|int8
|int16
|int32
|int64
|UINT8
|uint16
|UINT32
|Uint64
|duration
[KB KF]
—Directional window length
numeric or duration row vector containing two elements
Directional window length, specified as a numeric or duration row vector containing two elements. Whenkb
和kf
are positive integer scalars, the calculation is overKB+KF+1
元素。The calculation includes the element in the current position,kb
elements before the current position, andkf
当前位置之后的元素。例如,定向窗口定义的四点标准偏差[2 1]
results in the following calculation for a vectorA
:
Data Types:单身的
|double
|int8
|int16
|int32
|int64
|UINT8
|uint16
|UINT32
|Uint64
|duration
w
—Weight
0
(默认)|1
Weight, specified as one of these values:
0
— Normalize byk-1
, wherek
是窗口长度。如果k=1
,重量是k
。1
— Normalize byk
。
Data Types:单身的
|double
dim
—Dimension to operate along
positive integer scalar
Dimension to operate along, specified as a positive integer scalar. If no value is specified, then the default is the first array dimension whose size does not equal 1.
Dimensiondim
indicates the dimension thatmovstd
沿着指定的窗口滑动的方向运行。
Consider a two-dimensional input array,A
。
如果
DIM = 1
, thenmovstd(A,k,0,1)
starts with the first column and slides vertically over each row. The standard deviation is taken overk
一次元素。然后它移至第二列并重复计算。这个过程一直持续到所有列都用尽。论点0
specifies the default weight, which is required when specifyingdim
。如果
DIM = 2
, thenmovstd(a,k,0,2)
从第一行开始,然后在每列中水平滑动。标准偏差已接管k
一次元素。Then it moves to the second row and repeats the computation. This process continues until all rows are exhausted. The argument0
specifies the default weight, which is required when specifyingdim
。
Data Types:double
|单身的
|int8
|int16
|int32
|int64
|UINT8
|uint16
|UINT32
|Uint64
Nanflag
—NaN
(健康)状况
'includenan'
(默认)|'omitnan'
NaN
条件,指定为以下值之一:
'includenan'
- 包括NaN
values from the input when computing the standard deviation, resulting in the outputNaN
。'omitnan'
— Ignore allNaN
values in the input. If a window contains onlyNaN
values, thenmovstd
returnsNaN
。
姓名-Value Pair Arguments
Specify optional comma-separated pairs of姓名,Value
arguments.姓名
is the argument name and价值
是相应的值。姓名
must appear inside quotes. You can specify several name and value pair arguments in any order as姓名1,Value1,...,NameN,ValueN
。
m = movstd(A,k,'Endpoints','fill')
'端点'
—Method to treat leading and trailing windows
'shrink'
(默认)|'discard'
|'fill'
|numeric or logical scalar
Method to treat leading and trailing windows, specified as the comma-separated pair consisting of'端点'
和one of the following:
'端点' 价值 |
Description |
---|---|
'shrink' |
Shrink the window size near the endpoints of the input to include only existing elements. |
'discard' |
不输出任何标准差时赢了吗dow does not completely overlap with existing elements. |
'fill' |
Substitute nonexisting elements withNaN 。 |
numeric or logical scalar | Substitute nonexisting elements with a specified numeric or logical value. |
Data Types:double
|单身的
|int8
|int16
|int32
|int64
|UINT8
|uint16
|UINT32
|Uint64
|logical
|char
|细绳
'SamplePoints'
—Sample points for computing standard deviations
向量
Sample points for computing standard deviations, specified as the comma-separated pair consisting of'SamplePoints'
和矢量。样品点表示数据的位置A
。样品点不需要均匀采样。默认情况下,示例点向量为[1 2 3 ... ]
。
移动窗口是相对于样品点定义的,该点必须对其进行排序并包含唯一的元素。例如,如果t
is a vector of times corresponding to the input data, thenmovstd(rand(1,10),3,'SamplePoints',t)
has a window that represents the time interval betweent(i)-1.5
和t(i)+1.5
。
什么时候the sample points vector has data type约会时间
或者duration
,然后移动的窗口长度必须具有类型duration
。
如果the sample points are nonuniformly spaced and the'端点'
name-value pair is specified, then its value must be'shrink'
。
Data Types:单身的
|double
|int8
|int16
|int32
|int64
|UINT8
|uint16
|UINT32
|Uint64
|约会时间
|duration
More About
Standard Deviation
对于随机变量向量Amade up ofNscalar observations, the standard deviation is defined as
在哪里μis the mean ofA:
The standard deviation is the square root of the variance. Some definitions of standard deviation use a normalization factor ofNinstead ofN-1,您可以通过设置指定w
至1
。
扩展功能
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
This function supports tall arrays with the limitations:
The'SamplePoints'
不支持名称值对。金宝app
For more information, seeTall Arrays。
C/C++ Code Generation
使用MATLAB®CODER™生成C和C ++代码。
This function supports C/C++ code generation with the limitations:
The'SamplePoints'
不支持名称值对。金宝app
GPU Arrays
使用并行计算工具箱™在图形处理单元(GPU)上运行加速代码。
Usage notes and limitations:
The
'SamplePoints'
不支持名称值对。金宝app
For more information, seeRun MATLAB Functions on a GPU(并行计算工具箱)。
Introduced in R2016a
Open Example
A modified version of this example exists on your system. Do you want to open this version instead?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
选择一个网站以获取可用的翻译内容,并查看本地事件和优惠。根据您的位置,我们建议您选择:。
您还可以从以下列表中选择一个网站:
如何获得最佳网站性能
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina(Español)
- Canada(English)
- United States(English)