Find the intersection points of two ListPlot in Mathematica

I have two sets of discrete data that I draw as two different colors (red and blue) with ListPlot in Mathematica. I want to find the intersection points (corresponding continuous curves) between the two, that is, point A and B, as shown.

enter image description here

I tried the FindCluster method and jumped to get subsets of the data lines, but this does not work very well.

Now I always use the GetCoordinate property to get numbers from the graph directly. It would be nice to have a way to do this automatically and more accurately.

+4
source share
1 answer

I'm not sure if this will be convenient in your case, but I sometimes allow Mathematica to interpolate point lists and then decide for the intersection:

  findGuesses [pointsTable1_, pointsTable2_]: = 
      Block [{interpolatingPolyF1, interpolatingPolyF2},
       interpolatingPolyF1 = 
        Function [{x}, Evaluate [InterpolatingPolynomial [pointsTable1, x]]];
       interpolatingPolyF2 = 
        Function [{x}, Evaluate [InterpolatingPolynomial [pointsTable2, x]]];
       (* Print [Plot [{interpolatingPolyF1 [x], interpolatingPolyF2 [x]}, {x, 0,2}]]; *)
       {x, y} /. 
        NSolve [{y == interpolatingPolyF1 [x], 
          y == interpolatingPolyF2 [x]}, {x, y}, Reals]
       ]
0
source

Source: https://habr.com/ru/post/1439739/


All Articles