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

1 Ansicht (letzte 30 Tage)
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 Kommentar
David Haydock
David Haydock am 26 Okt. 2021
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?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt J
Matt J am 26 Okt. 2021
[I,J]=find(yourMatrix);
keep=(J>=I);
I=I(keep);
J=J(keep);

Weitere Antworten (0)

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!

Translated by