MATLAB: How to identify the indices of rows containing all NaNs from matrix

identifying indexrows with nan

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.

Best Answer

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