How to find location/coordinates of NaN in a sort condition?

조회 수: 6 (최근 30일)
Isti
Isti 2012년 4월 27일
I have a matrix like this:
3 2 3 6 2
9 4 NaN 4 2
NaN 3 2 4 3
7 2 NaN 9 3
7 1 8 2 4
So the location/coordinates NaN that will be out in a sort condition is(2,3),(3,1), and(4,3).
I've already try this code:
[I,J] = find(isnan(Data));
but the value does't well organized. is the any solution? thanks before :')

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 4월 27일
[ii jj] = find(isnan(Data));
outij = sortrows([ii jj],1);
OR
[jj ii] = find(isnan(Data.'))
  댓글 수: 2
Jan
Jan 2012년 4월 27일
Matrices are store in column order in Matlab. Therefore the output of FIND *is* well organized, but not in the order you expect.
Isti
Isti 2012년 4월 28일
thanks :)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by