How to return value of column not the index using find function?

조회 수: 7 (최근 30일)
Ahmed Hamed
Ahmed Hamed 2016년 4월 30일
댓글: Ahmed Hamed 2016년 4월 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

채택된 답변

Azzi Abdelmalek
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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by