Azzera filtri
Azzera filtri

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

2 visualizzazioni (ultimi 30 giorni)
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 Commento
David Haydock
David Haydock il 26 Ott 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?

Accedi per commentare.

Risposta accettata

Matt J
Matt J il 26 Ott 2021
[I,J]=find(yourMatrix);
keep=(J>=I);
I=I(keep);
J=J(keep);

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by