# How to find the position of a real vector in a matrix?

1 view (last 30 days)
Cantor Set on 6 Mar 2020
Edited: dpb on 7 Mar 2020
I do have a very big matrix of real numbers, I need a function that takes a vector as input and returns its position in the matrix.
An example:
A =[
0.7081 0.0797 0.1418 0.5849 0.1305
0.0738 0.4849 0.5060 0.8479 0.5003
0.8723 0.1511 0.6346 0.0683 0.7673
0.2021 0.4461 0.7313 0.7355 0.4157
0.7050 0.8435 0.8158 0.2139 0.8008]
Suppose I want to find the position of
v=[ 0.7081 0.0797 0.1418 0.5849 0.1305]
in A
How can I do it?
I edited the question
##### 2 CommentsShowHide 1 older comment
Cantor Set on 6 Mar 2020
Sorry, I edited the question

dpb on 6 Mar 2020
>> find(ismember(A,v,'rows'))
ans =
1
>>
works here, but in general for floating point values
>> find(ismembertol(A,v,2*eps,'byrows',1))
ans =
1
>>
is more robust and will avoid surprises.
##### 2 CommentsShowHide 1 older comment
dpb on 7 Mar 2020
>> find(ismembertol(w,c,2*eps,'byrows',1))
ans =
1
>>

Walter Roberson on 6 Mar 2020
Dists = pdist2(A, v);
[mindist, rowidx] = min(Dists) ;
if mindist > some_tolerance
end
Walter Roberson on 7 Mar 2020

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by