Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Get line index on matrix
Date: Thu, 5 Nov 2009 12:03:02 +0000 (UTC)
Organization: The MathWorks Inc
Lines: 34
Message-ID: <hcuetm$6t$1@fred.mathworks.com>
References: <hcudtq$phk$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257422582 221 172.30.248.38 (5 Nov 2009 12:03:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 5 Nov 2009 12:03:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1597503
Xref: news.mathworks.com comp.soft-sys.matlab:582690


"Joe Nunes" <vazdepaivanunes@gmail.com> wrote in message <hcudtq$phk$1@fred.mathworks.com>...
> Hello,
> 
> I'm trying to get the line index of a nx3 matrix for a given vector (1x3), like
> 
> 0.1  0.3  1.6
> 0.2  0.7  1.2
> 1.3  0.1  7.3
> (...)
> 
> searching for vector = 0.2 0.7 1.2 should return index = 2.
> 
> i've tried find() and a script which compares
> 
>     if(vector(i,:) == points(i,:))
>         index = i;
> 
> inside a for() loop (but it says that the condition is not valid, on debug)
> 
> I would appreciate your help.
> 
> Best regards

Hi Joe, will the following work for you?

A=[0.1 0.3 1.6
0.2 0.7 1.2
1.3 0.1 7.3];
B= [0.2 0.7 1.2];
[C,IA] = intersect(A,B,'rows');
% IA is equal to 2
IA

Wayne