How to find points between two intersecting lines?

3 ビュー (過去 30 日間)
Niraj Bal Tamang
Niraj Bal Tamang 2021 年 5 月 22 日
コメント済み: Niraj Bal Tamang 2021 年 5 月 26 日
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 件のコメント
Image Analyst
Image Analyst 2021 年 5 月 23 日
Those lines are not on your graph.
Niraj Bal Tamang
Niraj Bal Tamang 2021 年 5 月 23 日
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

サインインしてコメントする。

採用された回答

G A
G A 2021 年 5 月 23 日
編集済み: G A 2021 年 5 月 23 日
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 件のコメント
G A
G A 2021 年 5 月 26 日
load('H_usarea_and_slope.mat',"usarea","slope")
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
grid on
X=usarea;
Y=slope;
Y1=ones(size(X))*0.15; % horizontal line
B=1e7; % vertical line, I shifted it to the right for demonstration purpose
% defining diagonal line as log(y)=a*log(x)+b
x1=log(7e5);
x2=log(5e9);
y1=log(0.2);
y2=log(1e-4);
a=(y2-y1)/(x2-x1);
b=y1-a*x1;
Y2=exp(a*log(X)+b); % diagonal line
Y3 = Y(Y < Y1 & Y > Y2 & X > B); % Y-data between lines
X3 = X(Y < Y1 & Y > Y2 & X> B); % X-array
plot(X3,Y3,'.r');
plot(X,Y1,'--b');
plot(X,Y2,'--g');
xline(B,'--m');
hold off
Niraj Bal Tamang
Niraj Bal Tamang 2021 年 5 月 26 日
Thank you so much.It's working now.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by