Data Analysis - The MathWorks - #15

/ 220


catalogue search
P. 01
P. 02
P. 03
P. 04
P. 05
P. 06
P. 07
P. 08
P. 09
P. 10
P. 11
P. 12
P. 13
P. 14
P. 15
P. 16
P. 17
P. 18
P. 19
P. 20
P. 21
P. 22
P. 23
P. 24
P. 25
P. 26
P. 27
P. 28
P. 29
P. 30
P. 31
P. 32
P. 33
P. 34
P. 35
P. 36
P. 37
P. 38
P. 39
P. 40
P. 41
P. 42
P. 43
P. 44
P. 45
P. 46
P. 47
P. 48
P. 49
P. 50


See other catalogues for The MathWorks

Text version of the page
Missing Data
Notice that the sum of the elements in the middle column is a NaN value because that column contains a NaN.
If you do not want to have NaNs in your final results, you must remove these values from your data. For more information, see "Removing NaNs from Data" on page 1-7.
Removing NaNs from Data
You can use the IEEE function isnan to identify NaNs in the data, and then remove them using the techniques in the following table.
Note You must use the function isnan to identify NaNsbecause,byIEEE arithmetic convention, the logical comparison NaN == NaN always produces 0 (i.e., it never evaluates to true). Therefore, you cannot use x(x==NaN) = [] to remove NaNs from your data.
Code
Description
i = find(~isnan(x)) ; x = x(i)
Find the indices of elements in a vector x that are not NaNs. Keep only the non-NaN elements.
x = x(~isnan(x));
Remove NaNs from a vector x.
x(isnan(x)) = [];
Remove NaNs from a vector x (alternative method).
Remove any rows containing NaNs from a matrix X.
If you frequently need to remove NaNs, you might want to write a short M-file function that you can call:
function X = exciseRows(X)
1-7

pageCatalog pdf di En 2012-06-22-01