フィルターのクリア

finding column # that contains an integer in a matrix

5 ビュー (過去 30 日間)
mehrdad asadi
mehrdad asadi 2015 年 7 月 7 日
コメント済み: mehrdad asadi 2015 年 7 月 7 日
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

採用された回答

James Tursa
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
James Tursa 2015 年 7 月 7 日
indices = find(any(X==5,2)); % rows that have the number 5 in them
mehrdad asadi
mehrdad asadi 2015 年 7 月 7 日
got it!
thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by