1

I have two Listsoflist containing x and y coordinates. Now, I want to plot the two profiles, show their intersection and find the area of each intersecting region. I have used interpolating function to find the plots but unable find intersection point.

1 Answers1

3

Creating fake data for example

list1 = {Range[20],Join[Range[10] + RandomReal[1, 10],10 - Range[10] + RandomReal[1, 10]]}//Transpose;
list2 = {Range[20],Join[10 - Range[10] + RandomReal[1, 10], Range[10] + RandomReal[1, 10]]}//Transpose;

Interpolating them:

f1 = Interpolation[list1];
f2 = Interpolation[list2];

Finding intersections:

roots = {FindRoot[f1[x] - f2[x] == 0, {x, 5}], 
   FindRoot[f1[y] - f2[y] == 0, {y, 15}]} // Flatten

{x -> 5.12575, y -> 14.9835}

Showing the plot:

Show[
 ListLinePlot[{list1, list2}, 
  Filling -> {2 -> {{1}, {LightBlue, Transparent}}}]
 ,
 ListPlot[{{x, f1[x]}, {y, f1[y]}} /. roots, PlotStyle -> Blue]
 ]

enter image description here

Integrating for finding the area:

NIntegrate[f1[z] - f2[z], {z, x, y} /. roots]

50.5077

Fraccalo
  • 6,057
  • 13
  • 28