Products & Services Solutions Academia Support User Community Company

Learn more about Statistics Toolbox   

nanstd - Standard deviation ignoring NaN values

Syntax

y = nanstd(X)
y = nanstd(X,1)
y = nanstd(X,flag,dim)

Description

y = nanstd(X) is the standard deviation std of X, computed after removing NaN values.

For vectors x, nanstd(x) is the sample standard deviation of the remaining elements, once NaN values are removed. For matrices X, nanstd(X) is a row vector of column sample standard deviations, once NaN values are removed. For multidimensional arrays X, nanstd operates along the first nonsingleton dimension.

If n is the number of remaining observations after removing observations with NaN values, nanstd normalizes y by n – 1. To specify normalization by n, use y = nanstd(X,1).

y = nanstd(X,flag,dim) takes the standard deviation along the dimension dim of X. The flag is 0 or 1 to specify normalization by n – 1 or n, respectively, where n is the number of remaining observations after removing observations with NaN values.

Examples

Find column standard deviations for data with missing values:

X = magic(3);
X([1 6:9]) = repmat(NaN,1,5)
X =
   NaN     1   NaN
     3     5   NaN
     4   NaN   NaN
y = nanstd(X)
y =
   0.7071  2.8284  NaN

See Also

NaN, std, nanvar, nanmean

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS