Question: How can I retrieve the indices of specific values in a matrix?

I have a matrix (M) and it has both 0 and 1 as entries. I want to have a sequence/list of all indices associated with the entries equal to one (the others are irrelevant to me). I can use a nested for loop with an if statement, but I find that the easy way out and not very pretty. Is there is more sophisticated way, hopefully faster way of achieving this (using sequences, attributes, select/remove)?



then the list I want is


which makes it easier afterwards to loop through the list with sequences, which is what I have to do.



Please Wait...