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

4 次查看(过去 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 CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by