Find NaN elements in a matrix
634 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Walter Roberson
on 12 Oct 2011
[row, col] = find(isnan(YourMatrix));
6 Comments
Ana Paulina García
on 5 Oct 2020
for me this actually creates a 1x0 variable named row and another one named col. None of the variables tells me the index :(
More Answers (3)
Wayne King
on 12 Oct 2011
One way:
X = ones(10,4);
X(3,4) = NaN;
indices = find(isnan(X) == 1);
[I,J] = ind2sub(size(X),indices);
0 Comments
Elizabeth Drybrugh
on 3 May 2018
Edited: Elizabeth Drybrugh
on 3 May 2018
Do this to get the sum
sum(isnan(x))
For other functions, it depends on what you actually need....
0 Comments
See Also
Categories
Find more on NaNs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!