Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Find index of point inside array

Subject: Find index of point inside array

From: J D

Date: 27 Aug, 2010 15:20:27

Message: 1 of 3

I have a point
H =
[x y]

The point H is inside an array of points that make a curve

F =

[x1 y1;
x2 y2;
x3 y3;
x4 y4;
x5 y5;
...]

How do i pick out the index of the point in the array?

example if [x y] = [x3 y3]

index(H,F) = 3

Subject: Find index of point inside array

From: Andy

Date: 27 Aug, 2010 15:46:23

Message: 2 of 3

"J D" <JD@USA.com> wrote in message <i58l3r$9v7$1@fred.mathworks.com>...
> I have a point
> H =
> [x y]
>
> The point H is inside an array of points that make a curve
>
> F =
>
> [x1 y1;
> x2 y2;
> x3 y3;
> x4 y4;
> x5 y5;
> ...]
>
> How do i pick out the index of the point in the array?
>
> example if [x y] = [x3 y3]
>
> index(H,F) = 3

data = reshape(1:10,5,2);
pt = [3 8];
[tf,loc] = ismember(pt,data,'rows');

Subject: Find index of point inside array

From: Roger Stafford

Date: 27 Aug, 2010 15:58:08

Message: 3 of 3

"J D" <JD@USA.com> wrote in message <i58l3r$9v7$1@fred.mathworks.com>...
> I have a point
> H =
> [x y]
>
> The point H is inside an array of points that make a curve
>
> F =
>
> [x1 y1;
> x2 y2;
> x3 y3;
> x4 y4;
> x5 y5;
> ...]
>
> How do i pick out the index of the point in the array?
>
> example if [x y] = [x3 y3]
>
> index(H,F) = 3
- - - - - - -
 p = find(all(bsxfun(@eq,F,H),2));

Roger Stafford

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us