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

8 views (last 30 days)
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 Comment
David Haydock
David Haydock on 26 Oct 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?

Sign in to comment.

Accepted Answer

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

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!