How to find point of intersection ?

4 ビュー (過去 30 日間)
thineesh Vijayakumar
thineesh Vijayakumar 2019 年 4 月 12 日
コメント済み: Star Strider 2019 年 4 月 12 日
I have 4 coordinate and need to find the point of intersection. Can someone share the coding to find the intersection point and to display the point in graph below. Thank You.mat.JPG

採用された回答

Star Strider
Star Strider 2019 年 4 月 12 日
Try this:
blue = [1 5; 1 5]; % [x1 x2; y1 y2]
red = [1 5; 3 2]; % [x1 x2; y1 y2]
Bb = [blue(1,:)' ones(2,1)] \ blue(2,:)'
Br = [red(1,:)' ones(2,1)] \ red(2,:)'
xint = (Br(2) - Bb(2)) / (Bb(1) - Br(1))
yint = [xint 1] * Bb
figure
plot(blue(1,:)', blue(2,:)', '-b')
hold on
plot(red(1,:), red(2,:), '-r')
plot(xint, yint, 'pg', 'MarkerSize',10)
hold off
producing:
xint =
2.6000
yint =
2.6000
  3 件のコメント
thineesh Vijayakumar
thineesh Vijayakumar 2019 年 4 月 12 日
編集済み: thineesh Vijayakumar 2019 年 4 月 12 日
plot(blue(1,:)', blue(2,:)', '-b')
hold on
plot(red(1,:), red(2,:), '-r')
plot(xint, yint, 'pg', 'MarkerSize',10)
hold off
what mean 'pg' ? thank you
Star Strider
Star Strider 2019 年 4 月 12 日
As always, my pleasure!
The 'pg' in the plot call denotes a green five-pointed star (‘pentagram’) marker. See the documentation section on Marker (link) for details.

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

その他の回答 (1 件)

darova
darova 2019 年 4 月 12 日
mat.jpeg

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by