How to find the position of specific entry in a Matrix?
16 次查看(过去 30 天)
显示 更早的评论
I have a matrix like
A=[3 2 1;3 1 2;2 3 1];
I want to find the position of 2 in each row
I need
1 2
2 3
3 1
which indicates that at first row it is in second column, at second row it is is in third column and at third row it is in first column,
Thanks
采纳的回答
Walter Roberson
2018-3-8
A = [3 2 1;3 1 2;2 3 1];
[r, c] = find(A == 2);
output = [r, c]
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!