Reputation: 343
I have a matrix in Matlab and want to find the indeces of all rows, where some of the columns meet a specific criteria.
Example
M =
1 5 9 13
2 6 10 14
10 14 11 15
4 8 10 14
Now I want to find the incedeces of all rows, where M(:,3) == 10 AND M(:,4) == 14
.
The result should be:
R =
0
1
0
1
I though about something like
find(ismember(M,[* * 10 14]),1)
but ismember()
won't work with wildcars.
Upvotes: 2
Views: 5820
Reputation: 272802
R = (M(:,3) == 10 & M(:,4) == 14);
should be sufficient.
Upvotes: 4