Intersection of Discretized Curves
Show older comments
Hi,
I have a scatter plot of two curves.
The curves intersect each other and ideally they should have one or more intersection points.
However, as I have discrete points and two curves do not intersect at any of those points, I can not get the point of intersection.
I'm attaching a figure for more clarity.

I believe I will have a set of points here instead a single point.
How do I get those set of points from the scatter plot data or the data points I have now?
Thanks..
2 Comments
Tony
on 21 Jun 2024
The pair of points on the two curves with the smallest Euclidean distance between them will be the intersection point. If you are looking for multiple, then you can put a threshold; e.g. find the pairs of points whose distance is less than 1e-6
Prasanna Routray
on 21 Jun 2024
Accepted Answer
More Answers (1)
Bruno Luong
on 5 Oct 2024
Edited: Bruno Luong
on 5 Oct 2024
Use this file exchange https://www.mathworks.com/matlabcentral/fileexchange/22441-curve-intersections
This code is robust, it doesn't break for repeating x or y coordinates.
The curves are assumed to me line segments connectings data points. Intersection coordinates of two line segments that meet are returned, and all of them.
x1 = -100:1:100;
y1 = 5*ones(size(x1));
y2 = -100:1:100;
x2 = 5*ones(size(y2));
X = InterX([x1; y1],[x2; y2]);
plot(x1,y1,'-',x2,y2,'-.',X(1,:),X(2,:),'or')

1 Comment
Prasanna Routray
on 5 Oct 2024
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

