How can I identify the indices of rows containing all NaNs from matrix?

조회 수: 17 (최근 30일)
I have very large matrices, in which some rows contain all NaN. I don't want to remove these rows. But I wish to identify which index contains all NaN. I have seen code for removing such rows, but how can I extract the index value?
I am not very familiar with MATLAB. Thanks in advance.

채택된 답변

Star Strider
Star Strider 2017년 5월 31일
Try this:
M = [rand(3,5); NaN(1,5); rand(4,5); NaN(1,5); rand(2,5)]; % Create Data
NaN_rows = find(all(isnan(M),2)); % Identify ‘NaN’ Rows By Index

추가 답변 (1개)

Chandrasekhar
Chandrasekhar 2017년 5월 31일
% idenfity NaN's in the matrix
k = isnan(a);
% find the indices of NaN's
find(k==1);
  댓글 수: 1
Deepa T
Deepa T 2017년 6월 1일
Thank you for your reply. This query helps me to identify every NaN in the dataset, not just the rows with all NaN.

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

카테고리

Help CenterFile Exchange에서 Correlation and Convolution에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by