finding column # that contains an integer in a matrix
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
mehrdad asadi
am 7 Jul. 2015
Kommentiert: mehrdad asadi
am 7 Jul. 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 Kommentare
Akzeptierte Antwort
James Tursa
am 7 Jul. 2015
Bearbeitet: James Tursa
am 7 Jul. 2015
X = your matrix;
indices = find(any(X==5)); % columns that have the number 5 in them
4 Kommentare
James Tursa
am 7 Jul. 2015
indices = find(any(X==5,2)); % rows that have the number 5 in them
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!