MATLAB Answers

0

How to find point of intersection ?

Asked by thineesh Vijayakumar on 12 Apr 2019
Latest activity Commented on by Star Strider
on 12 Apr 2019
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

  0 Comments

Sign in to comment.

2 Answers

Answer by Star Strider
on 12 Apr 2019
 Accepted Answer

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 Comments

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

Sign in to comment.


Answer by darova
on 12 Apr 2019

mat.jpeg

  0 Comments

Sign in to comment.