Main Content

(Not recommended) Standard deviation, ignoring `NaN`

values

`nanstd`

is not recommended. Use the MATLAB^{®} function `std`

instead. With the `std`

function, you can specify whether
to include or omit `NaN`

values for the calculation. For more information,
see Compatibility Considerations.

is the
standard deviation `y`

= nanstd(`X`

)`std`

of `X`

, computed after
removing all `NaN`

values.

If

`X`

is a vector, then`nanstd(X)`

is the sample standard deviation of all the non-`NaN`

elements of`X`

.If

`X`

is a matrix, then`nanstd(X)`

is a row vector of column sample standard deviations, computed after removing`NaN`

values.If

`X`

is a multidimensional array, then`nanstd`

operates along the first nonsingleton dimension of`X`

. The size of this dimension becomes 1 while the sizes of all other dimensions remain the same.`nanstd`

removes all`NaN`

values.By default,

`nanstd`

normalizes`y`

by*n*– 1, where*n*is the number of remaining observations after removing observations with`NaN`

values.

returns the standard deviation over the dimensions specified in the vector
`y`

= nanstd(`X`

,`flag`

,`vecdim`

)`vecdim`

. The function computes the standard deviations after removing
`NaN`

values. For example, if `X`

is a matrix, then
`nanstd(X,0,[1 2])`

is the sample standard deviation of all
non-`NaN`

elements of `X`

because every element of a
matrix is contained in the array slice defined by dimensions 1 and 2.