how i can find index of each element
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Mohamuud hassan
il 21 Mag 2015
Commentato: Andrei Bobrov
il 21 Mag 2015
hello all; i have one problem which
Ex_BWLasColum=[14;20;2;16;1;1;8;1;1;1;1;6;1;1;17;2;24;2;25;8;9;1;1;1;1;1;3;1;1;1;1;1;1;1;1;1];
Ex_BWFirscolm=[1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;1;2;2;2;3;6;8;8;9;14;16;17;20;24;25];
how i can find index of each element of Ex_BWFirscolm from Ex_BWLasColum.
0 Commenti
Risposta accettata
Andrei Bobrov
il 21 Mag 2015
Only in your case:
[~,ii] = sort(Ex_BWLasColum);
2 Commenti
Thorsten
il 21 Mag 2015
i.e., in the case where Ex_BWLasColum contains no elements that are not contained in Ex_BWFirscolm.
Più risposte (1)
the cyclist
il 21 Mag 2015
Modificato: the cyclist
il 21 Mag 2015
[tf,loc] = ismember(Ex_BWFirscolm, Ex_BWLasColum);
(Or maybe switch the input arguments. I'm not sure which way you meant.)
tf is a boolean that indicates whether the element is present, and loc is an index that tells you the location. It sounds like you want loc.
1 Commento
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!