I have some point and one line.

1 view (last 30 days)
Mili Kian
Mili Kian on 19 Apr 2020
Commented: Ameer Hamza on 21 Apr 2020
I have some point and one line.
my points are in (x,y) written in under
X = ...
[ 1 1
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
3 1
3 3
3 5
3 7
3 9
3 11
3 13
3 15
3 17
5 1
5 3
5 5
5 7
5 9
5 11
5 13
5 15
5 17
7 1
7 3
7 5
7 7
7 9
7 11
7 13
7 15
7 17
9 1
9 3
9 5
9 7
9 9
9 11
9 13
9 15
9 17
11 1
11 3
11 5
11 7
11 9
11 11
11 13
11 15
11 17
13 1
13 3
13 5
13 7
13 9
13 11
13 13
13 15
13 17
15 1
15 3
15 5
15 7
15 9
15 11
15 13
15 15
15 17
17 1
17 3
17 5
17 7
17 9
17 11
17 13
17 15
17 17];
and my line is
r=[0 10 15 20 30];
t=[10 10 15 10 10];
f= line(r,t)
how can i find wich points are under the line??
please help me its emergency
  2 Comments
David Welling
David Welling on 19 Apr 2020
Since there is only a small number of cases, you could do it by hand, especially since the line is so simple.
plot the line and the points and you will see it easily.
for a more general case using arbitrary points and lines, I suggest interpolating to find the y value of the line for a given x of the point, and then comparing y_line and y_point
Mili Kian
Mili Kian on 20 Apr 2020
these points were for example. in fact i have more than a hundread points.

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 20 Apr 2020
try this. X is the n*2 matrix given in your question
r=[0 10 15 20 30];
t=[10 10 15 10 10];
x = interp1(r,t, X(:,1));
mask = X(:,2) >= x;
plot(r, t, 'r', X(mask,1), X(mask,2), 'r*', X(~mask,1), X(~mask,2), 'b*')
  2 Comments
Mili Kian
Mili Kian on 21 Apr 2020
Thanks alot
this is the code that i want
best regard
Ameer Hamza
Ameer Hamza on 21 Apr 2020
Glad to be of help.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!