# i have number of points that have (x,y) .then i define a line and i want to realize which points are under the line?

2 views (last 30 days)

Show older comments

i write this :

....

r=[0 10 15 20 30];

t=[10 10 15 10 10];

f= line(r,t)

axis([0,30,0,20]);

d=(eldof(:,10))& (eldof(:,11)) <= f

then all of points are zero

why??

##### 0 Comments

### Accepted Answer

Image Analyst
on 18 Apr 2020

You need to call polyfit:

coefficients = polyfit(r, t, 1);

or you can call fitPolynomialRansac if you want the line to go exactly through the points on the bottom of your plot.

Then you have to get some x values and get a digital vector of line values. You can use your r locations, or you can use more or less than that. Then see which values are less than the y value of the line. For the same r points

yLine = polyval(coefficients, r);

belowLine = t < yLine; % A logical index vector.

##### 2 Comments

Image Analyst
on 20 Apr 2020

Those points are just a grid:

I'm not sure what to do either. Can you draw the line on there that you want to detect if some point is below that line, and repost your picture with the line indicated?

### More Answers (1)

### See Also

### Community Treasure Hunt

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

Start Hunting!