finding column # that contains an integer in a matrix
5 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
James Tursa
2015 年 7 月 7 日
編集済み: James Tursa
2015 年 7 月 7 日
X = your matrix;
indices = find(any(X==5)); % columns that have the number 5 in them
4 件のコメント
James Tursa
2015 年 7 月 7 日
indices = find(any(X==5,2)); % rows that have the number 5 in them
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!