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 15:04:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 56
Message-ID: <hcuph2$2mp$1@fred.mathworks.com>
References: <hcudtq$phk$1@fred.mathworks.com> <hcuetm$6t$1@fred.mathworks.com> <hcufeh$298$1@fred.mathworks.com> <hcugch$fv$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 1257433442 2777 172.30.248.38 (5 Nov 2009 15:04:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 5 Nov 2009 15:04:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2076570
Xref: news.mathworks.com comp.soft-sys.matlab:582751


i've tried forcing to double. that didn't work either. i don't have the bsxfun function, i've looked to ismember though .. =(

"Wayne King" <wmkingty@gmail.com> wrote in message <hcugch$fv$1@fred.mathworks.com>...
> "Joe Nunes" <vazdepaivanunes@gmail.com> wrote in message <hcufeh$298$1@fred.mathworks.com>...
> > "Wayne King" <wmkingty@gmail.com> wrote in message <hcuetm$6t$1@fred.mathworks.com>...
> > > "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
> > 
> > Yes, i've tried, but IA returns an Empty matrix: 0-by-1 .. Since my set of points is 1312x3 and the points to find are in 17x3, i've tried 
> > [C,IA] = intersect(points,keypoints(2,:),'rows')
> > 
> > but it keeps returning empty matrix. Is this because of rounding or something ? i don't understand. This points from 17x3 matrix were taken from the original set.
> 
> Hi, Maybe.. are you doing this inside of an M-file? If you do it in the command window (outside of an M-file) does it work? How about if you force them both to be doubles?
> 
> s = RandStream('mt19937ar');
> RandStream.setDefaultStream(s);
> A = randn(1000,3);
>  B=A(4,:);
>  [C,IA] = intersect(double(A),double(B),'rows');
> % IA is 4
> IA
> 
> wayne