Removing NaN in 3D array
显示 更早的评论
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
采纳的回答
更多回答(1 个)
Irene
2011-11-4
0 个投票
1 个评论
Walter Roberson
2011-11-4
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Arithmetic 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!