deleting NaNs in a column without changing the size of the matrix
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi
I used this script to delete a few NaN s I have in column 5 of a file, However, the size of the matrix changed too. How should I change the edit the script to keep the size of the matrix the same?
Than you
dataEEG(isnan(dataEEG(:,5)),:) = [];
댓글 수: 3
Rik
2019년 1월 20일
Even sparse matrices have a value at the positions that aren't filled. The only data type that can have empty elements is the cell:
C={1,[],3;4,5,6}
채택된 답변
Image Analyst
2019년 1월 20일
No you can't. If you delete the rows, the matrix will shrink. What you can do is to either set the nan elements to some known, constant value, or to fill in the nan regions with data from surrounding regions with something like regionfill() or a modified median filter. Would you like to do that? With regionfill() there is no max region size to fill in, but for a modified median filter you'd have to know the largest size of nan region in advance, which you can find.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 NaNs에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!