Sahil Chaudhary
Sahil Chaudhary

Reputation: 503

using find() in matlab

Say I have a matrix A of dimension Nx3 where N is the number of rows. A stores coordinates x,y,z. Now say I already have a set of known coordinates B = [x' y' z'] which I wanna look up in A. I wanna find out the number of which row index in A stores (x',y',z'). How can I do this? I am guessing I will have to use find()

Upvotes: 4

Views: 4214

Answers (1)

bla
bla

Reputation: 26069

you can use find, for example

find(A(:,1)==B(1) & A(:,2)==B(2) & A(:,3)==B(3))

will yield the index of the row\rows that match.

Try to get use to reading the documentation of Matlab, it is all there...

by the way, an alternative is to use ismember:

[~,id]=ismember(B,A,'rows')

the variable id will yield the index of the rows where B matched A.

Upvotes: 5

Related Questions