Removing NaN in 3D array
Afficher commentaires plus anciens
Hi all,
I am working on a 3D array (x,y,t) where I wanted to remove any row containing Nan values. I don't want to reshape my data in a 2D matrix and perform the removal process. Is there a way to do it directly from a 3D data?
thanks, Irene
Réponse acceptée
Plus de réponses (1)
Irene
le 4 Nov 2011
0 votes
1 commentaire
Walter Roberson
le 4 Nov 2011
Suppose you had 8 rows containing NaN. You start with 101*101 = 10201 rows, and you end with 10201-8 = 10193 rows. Now you want to reshape that in to a 3D matrix. How would you do that, considering that 10193 is a prime number?
The best you will be able to do and retain your 3D structure is to set the entire content of the row containing NaN to be some constant value -- e.g., negative infinity, infinity, NaN, whatever.
Another possibility to consider would be John D'Errico's MATLAB File Exchange contribution http://www.mathworks.com/matlabcentral/fileexchange/4551 "inpaint_nans", which will interpolate values for the NaN locations by examining the surrounding locations.
Catégories
En savoir plus sur Image Arithmetic dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!