finding column # that contains an integer in a matrix
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
mehrdad asadi
le 7 Juil 2015
Commenté : mehrdad asadi
le 7 Juil 2015
hi,
I want to find indices of columns of a matrix which contains a specific integer.
say magic(5), how can I find column numbers that has got '5' in it if it exists!
thanks,
Mehrdad
0 commentaires
Réponse acceptée
James Tursa
le 7 Juil 2015
Modifié(e) : James Tursa
le 7 Juil 2015
X = your matrix;
indices = find(any(X==5)); % columns that have the number 5 in them
4 commentaires
James Tursa
le 7 Juil 2015
indices = find(any(X==5,2)); % rows that have the number 5 in them
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!