COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

Help with finding index

• Email
• Follow

```I have an array of say :

a =

2     3     4
5     6     2
4     2     1
7     2     4

I want to find the index of an exact vector.
For instance,  I want to find the row index of vector [4 2 1], answer is 3(row 3).
The vector [7 2 4] will return index 4.

The find function does not work , any suggestion.
```
 0

See related articles to this posting

```ade77 wrote:
> I have an array of say :
....>
> I want to find the index of an exact vector.
> For instance,  I want to find the row index of vector ...

doc intersect

--
```
 0

```dpb <none@non.net> wrote in message <he7677\$3mi\$1@news.eternal-september.org>...
> > I have an array of say :
> ...>
> > I want to find the index of an exact vector.
> > For instance,  I want to find the row index of vector ...
>
> doc intersect
>
> --

Thank you. Works perfectly
```
 0

```Hi,

the "Intersect" function works well in this case, but if  I have this matrix

a =

4 2 1
5 6 2
4 2 1
7 2 4

And, If I want to find "all' rows index of vector [4 2 1], answers are rows 1 and 3.
[i,ii,iii]=Intersect(a,[4 2 1],'rows')  give just the last row index, (3) in this case.
```
 0

```Look at ismember with the rows option.
```
 0

```"LCPC Yannick" <yannick.fargier@hotmail.fr> wrote in message <hfogon\$jrk\$1@fred.mathworks.com>...
> Hi,
>
> the "Intersect" function works well in this case, but if  I have this matrix
>
> a =
>
>      4 2 1
>      5 6 2
>      4 2 1
>      7 2 4
>
> And, If I want to find "all' rows index of vector [4 2 1], answers are rows 1 and 3.
> [i,ii,iii]=Intersect(a,[4 2 1],'rows')  give just the last row index, (3) in this case.

STRMATCH will also work

>> strmatch([4 2 1], a)

ans =

1
3
```
 0

```thank you Matt & Matt, it works perfectly.
```
 0