Standard deviation, ignoring `NaN`

values

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.

Instead of using `nanstd`

, you can use the MATLAB^{®} function `std`

with the input argument
`nanflag`

specified as the value `'omitnan'`

.