Possible Duplicate:
Find rows in matrix where entries match certain constraints?
In Matlab, i have a matrix (MxN) and I want to find the rows whose entry in a specific column is equal to a specified value. For example, I have a matrix as follow:
0 0 0 0 0 0 0 0 1 0
1 0 0 0 0 0 1 0 0 1
0 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 1 0
0 0 0 0 1 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0
0 1 1 0 0 0 1 0 1 0
0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 1
I want to find the rows whose 7th element us equal to 1. In this example, the result matrix should contains rows 2 and 7.
if your matrix is called
A, just do:PS: I think that this question has already been answered a million times…