Intersection of Discretized Curves
Mostra commenti meno recenti
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 Commenti
Tony
il 21 Giu 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
il 21 Giu 2024
Risposta accettata
Più risposte (1)
Bruno Luong
il 5 Ott 2024
Modificato: Bruno Luong
il 5 Ott 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 Commento
Prasanna Routray
il 5 Ott 2024
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


