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!