How to return value of column not the index using find function?
8 次查看(过去 30 天)
显示 更早的评论
I have a simple matrix
A=
1 3
4 2
2 1
3 3
5 2
I'd like to search for all values in the first column whose second column is 3
When i use
find(A(:,2)==3)
I returns the index not the value of the first column?
Is there any matlab function that can do this?
That in advance
0 个评论
采纳的回答
Azzi Abdelmalek
2016-4-30
编辑:Azzi Abdelmalek
2016-4-30
out= A(A(:,2)==3,1)
Also, with your code you found the indices
idx=find(A(:,2)==3)
The the result is
R=A(idx,1)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!