MATLAB: 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

linepoint

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?
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??

Best Answer

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.