See other catalogues for
The MathWorks
You may also be interested in
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 | | |
| | | |
| | | | | | | | | | | | | | | | |