Mathematics |
This section tells you how to work with
Missing Values
The special value, NaN
, stands for Not-a-Number in MATLAB. IEEE floating-point arithmetic convention specifies NaN
as the result of undefined expressions such as 0/0
.
The correct handling of missing data is a difficult problem and often varies in different situations. For data analysis purposes, it is often convenient to use NaN
s to represent missing values or data that are not available.
MATLAB treats NaN
s in a uniform and rigorous way. They propagate naturally through to the final result in any calculation. Any mathematical calculation involving NaN
s produces NaN
s in the results.
For example, consider a matrix containing the 3-by-3 magic square with its center element set to NaN
.
Compute a sum for each column in the matrix.
Any mathematical calculation involving NaN
s propagates NaN
s through to the final result as appropriate.
You should remove NaN
s from the data before performing statistical computations. Here are some ways to use isnan
to remove NaN
s from data.
If you frequently need to remove NaN
s, write a short M-file function.
Finite Differences | Removing Outliers |
© 1994-2005 The MathWorks, Inc.