Find the point between indices where two curves with unknown equations intersect
3 views (last 30 days)
Show older comments
Hi,
I have two curves that intersect when plotted on the same graph. I would like to find the point at which they intersect. I do not have the equations to describe the curves as they are just two sets of x- and y-coordinates, and the point of intersection falls somewhere between two indices.
(The real problem that I tried to simplify for myself as I'm a programming novice: I actually have one set of x- and y-coordinates that form a curve that intersects with itself. Again, I do not know the equation for this curve and the intersection point falls between two indices. I looked at some of the answers that were previous posted in response to a similar question, but the solution was more complicated than I was able to understand.)
I would appreciate any sort of direction, please, keeping in mind that I've just been newly introduced to Matlab! Thanks so much!
Jessica
0 Comments
Answers (1)
John D'Errico
on 27 May 2014
As long as you are willing to find the intersections of the piecewise-linear curves that interpolate your points using connect-the-dots, then look on the file exchange. For example, Doug's intersections code is very nice.
Your question is not very clear, so I'm not sure if you are looking for the intersections of separate curves, or for the intersection points of a self intersecting curve. In any event, Doug's code handles either case.
2 Comments
Matt J
on 28 May 2014
Edited: Matt J
on 28 May 2014
I just have the x- and y-coordinates and do not have the equation to the curve as he does in his example.
I don't see anything in Doug's code that requires you to supply an equation for the curve or deviates from your situation in any way. The input syntax in his help documentation asks only for lists of (x,y) pairs, exactly what you say you have:
[X0,Y0] = intersections(X1,Y1,X2,Y2,ROBUST);
He also supports a syntax for the original situation you describe, where you want to find the self-intersections of a single curve.
[X0,Y0] = intersections(X1,Y1,ROBUST);
The code always assumes that the continuous "equation" for the curve is that all the (x,y) points are to be connected with line segments. So, you have to decide if you are happy with that approximation (if not, you need to decide what the alternative should be). Presumably, the code also assumes that your list of (x,y) data is ordered so that adjacent points on a curve are also adjacent in the list.
See Also
Categories
Find more on 2-D and 3-D 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!