How do I get the indexes of a symmetrical logical matrix without getting repetitions of those indexes?

8 ビュー (過去 30 日間)
I have a matrix of logical values that is symmetrical. All are zeros except for a few 1's. I need to get the indexes of the 1's without having two different iterations of the indexes due to the symmetrical nature of the matrix. How would I do this?
  1 件のコメント
David Haydock
David Haydock 2021 年 10 月 26 日
0 0 0 0 1 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 0 0 1 0
0 1 0 0 0 0 0 0
1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0
0 0 0 0 0 1 0 0
Here is the matrix. I need the row and column index of each one. I can do that. But, for example, I will have (1,5) and (5,1). How do I ensure I only have one of them?

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

採用された回答

Matt J
Matt J 2021 年 10 月 26 日
[I,J]=find(yourMatrix);
keep=(J>=I);
I=I(keep);
J=J(keep);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by