Elements in a matrix

4 ビュー (過去 30 日間)
Maik Petersen
Maik Petersen 2014 年 1 月 4 日
回答済み: Maik Petersen 2014 年 1 月 4 日
Hello,
When I have a certain matrix, is there a possibility to check whether some value is on more than one position in the matrix.
So for example the identity matrix 3-by-3, how can I check whether the value '1' is multiple times there in the matrix?
Thanks in advance.

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 1 月 4 日
Idx=find(A==1)

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2014 年 1 月 4 日
sum(TheMatrix(:) == TheValue) > 1
In the more general case where you want to know whether any value is repeated, see unique()

Maik Petersen
Maik Petersen 2014 年 1 月 4 日
You guys are great, thanks!

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by