I have a matrix like
A = [ 0 1 1;0 0 0;1 1 0]
For this, I wish to know indices of 1
's in such a manner that:
For row 1, I need values of indices of column where its coming equal 1
. Similarly for row 2 and row 3.
Later, I want to repeat this exercise for column, like for column 1, I need the value of indices of rows where its coming equal to 1
. and similarly for column 2 and column 3.
The ans
should be like this :
- for row 1 - indices are: 2,3
- for row 2 - indices are: 0
- for row 3 - indices are: 1,2
Similarly:
- for column 1 - indices are: 3
- for column 2 - indices are: 1,3
- for column 3 - indices are: 1
Please help.