How to return value of column not the index using find function?
20 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Ahmed Hamed
il 30 Apr 2016
Commentato: Ahmed Hamed
il 30 Apr 2016
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 Commenti
Risposta accettata
Azzi Abdelmalek
il 30 Apr 2016
Modificato: Azzi Abdelmalek
il 30 Apr 2016
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)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!