Hi Guys,
How can I find the exact location of NaN elements in a matrix. I work with really large arrays (size 1500*200).
How can I find which row has a NaN value in a column matrix or vice versa.?
Thanks
N

 채택된 답변

Walter Roberson
Walter Roberson 2011년 10월 12일

41 개 추천

[row, col] = find(isnan(YourMatrix));

댓글 수: 6

Wayne King
Wayne King 2011년 10월 12일
@Walter Now, that's a better way :)
NS
NS 2011년 10월 12일
Works fine. Thanks Walter. :)
Jaspalsingh Virdi
Jaspalsingh Virdi 2018년 8월 16일
Thanks for a quick help even my data was too lARGE
Anirban Mandal
Anirban Mandal 2020년 3월 19일
thanks for providing an efficient solution
Ana Paulina García
Ana Paulina García 2020년 10월 5일
for me this actually creates a 1x0 variable named row and another one named col. None of the variables tells me the index :(
Whitney
Whitney 2021년 11월 22일
An empty result means that there are no NaNs in the martix

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Wayne King
Wayne King 2011년 10월 12일

6 개 추천

One way:
X = ones(10,4);
X(3,4) = NaN;
indices = find(isnan(X) == 1);
[I,J] = ind2sub(size(X),indices);
bym
bym 2011년 10월 12일

0 개 추천

isnan()

댓글 수: 1

NS
NS 2011년 10월 12일
This gives me just an array of 0 and 1. I need more precise info :(

댓글을 달려면 로그인하십시오.

Elizabeth Drybrugh
Elizabeth Drybrugh 2018년 5월 3일
편집: Elizabeth Drybrugh 2018년 5월 3일

0 개 추천

Do this to get the sum
sum(isnan(x))
For other functions, it depends on what you actually need....

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

NS
2011년 10월 12일

댓글:

2021년 11월 22일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by