MATLAB Answers

How to find points between two intersecting lines?

1 view (last 30 days)
Niraj Bal Tamang
Niraj Bal Tamang on 22 May 2021
Commented: Niraj Bal Tamang on 26 May 2021
I have two straight lines defined by equations (say) x+y=3 and 2x-3y=4. I have to find out the points which lies between these two lines in the xy plot as in the attached figure. Can anyone suggest me how can i find the points between two lines in a plot?
Thank You
  2 Comments
Niraj Bal Tamang
Niraj Bal Tamang on 23 May 2021
Sorry. I just gave a random equations of straight line for assumption. I am attaching the whole code and variables if you want to give it a try. I am trying to get the points between each of those lines for classification.
scatter(usarea,slope);
set(gca,'xscale','log','yscale','log');
xlabel('Upstream Drainage Area (sq km)');
ylabel('Slope (m/m)');
hold on
xline(7*10^5,'Color','r','LineStyle','--');%vertical line
hold on
plot([1.1*10^6 10^10],[0.15 0.15],'--r');%horizontal line
hold on
plot([7*10^5 5*10^9],[0.2 10^-4],'--r');%diagonal line
hold off
grid on

Sign in to comment.

Accepted Answer

G A
G A on 23 May 2021
Edited: G A on 23 May 2021
myData = [X,Y];
y1 = 3 - X;
y2 = 2/3*X + 4/3;
Y1 = Y(Y < y2 & Y > y1);
X1 = X(Y < y2 & Y > y1); % or X1 = X(Y == Y1)
myData1 = [X1,Y1];
  4 Comments

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by