| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Statistics Toolbox |
| Contents | Index |
| Learn more about Statistics Toolbox |
y = nanvar(X)
y
= nanvar(X,1)
y = nanvar(X,w)
y = nanvar(X,w,dim)
y = nanvar(X) is the variance var of X, computed after removing NaN values.
For vectors x, nanvar(x) is the sample variance of the remaining elements, once NaN values are removed. For matrices X, nanvar(X) is a row vector of column sample variances, once NaN values are removed. For multidimensional arrays X, nanvar operates along the first nonsingleton dimension.
nancov removes the mean from each variable (column for matrix X) before calculating Y. If n is the number of remaining observations after removing observations with NaN values, nanvar normalizes y by either n – 1 or n , depending on whether n > 1 or n = 1, respectively. To specify normalization by n, use y = nanvar(X,1).
y = nanvar(X,w) computes the variance using the weight vector w. The length of w must equal the length of the dimension over which nanvar operates, and its elements must be nonnegative. Elements of X corresponding to NaN values of w are ignored.
y = nanvar(X,w,dim) takes the variance along the dimension dim of X. Set w to [] to use the default normalization by n – 1.
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 = nanvar(X)
y =
0.5000 8.0000 NaN![]() | nansum | nbincdf | ![]() |

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 |