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!