Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Is there any non loop implement to find the index of a vector  in the matrix?
Date: Sun, 14 Dec 2008 15:21:02 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 26
Message-ID: <gi388u$ed0$1@fred.mathworks.com>
References: <gi31mu$sqn$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1229268062 14752 172.30.248.35 (14 Dec 2008 15:21:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 14 Dec 2008 15:21:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:506885


"zedong"
> Is there any non loop implement to find the index of a vector  in the matrix?
> for example:
> a=[1 2]
> b=[4 5;6 7;8 7;1 2;2 3]
> I want to return  4

one of the solutions

% the data
     a=[
          1,2 % <- pos 4
          4,5 % <- pos 1
     ];
     b=[4 5;6 7;8 7;1 2;2 3];
% the engine
     [ix,ix]=ismember(a,b,'rows');
% the result
     ix
%{
     ix =
          4
          1
%}

us