Find function - index by rows?
이전 댓글 표시
For the find function, I noticed that it indexes downward column by column. Is there a way to make it so that it indexes left to right row by row?
댓글 수: 1
Stephen23
2016년 4월 27일
Nope. Transpose your data and start thinking in terms of columns, not rows.
답변 (2개)
Azzi Abdelmalek
2016년 4월 27일
Apply find function to the transpose of your matrix
find(A'==2) % for example
댓글 수: 2
Eric Tran
2016년 4월 27일
Azzi Abdelmalek
2016년 4월 27일
You are not changing your Matrix, your are just operating on another Matrix which is A'
Andrei Bobrov
2016년 4월 27일
편집: Andrei Bobrov
2016년 4월 27일
Example:
A = rand(15) > .4; % your array
[i0,j0] = find(A);
c = num2cell(sortrows([i0,j0],1),1);
[i_out,j_out] = c{:};
or jast (as by Azzi)
[j_out,i_out] = find(A.');
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!