Find given row in a matrix

EDIT:

gnovice’s suggestion is even simpler than mine:

[~,indx]=ismember(X,M,'rows')

indx =

     3

FIRST SOLUTION:

You can easily do it using find and ismember. Here’s an example:

M=magic(4);        %#your matrix

M =

    16     2     3    13
     5    11    10     8
     9     7     6    12
     4    14    15     1

X=[9 7 6 12];      %#your row vector

find(ismember(M,X),1)

ans =

     3

Leave a Comment