Indexing every value from matrix not only unique values
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello
For example if I have a matrix like:
A =[ 2 , 2 , 4 , 1 ,3 ;
3 , 1 , 10 , 100]
Is there a posibility to find the index of each value? I tried with find function but it is not working for same values and based on my research I found only solutions either for the same values from the matrix or unique. Not a combination.
Thank you!
0 Commenti
Risposta accettata
Jan
il 20 Lug 2021
Of course you can use find():
A = [2, 2, 4, 1, 3; ...
3, 1, 10, 100, 200]; % 200 added to match number of elements per row...
[i1, i2] = find(A == 2)
Now you get the row and column indices of the elements, which are 2.
Do you want to distinguish all elements even if they have the same number? Then this is trivial: Just use the indices.
8 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!