You might think that calculating intersection points is pretty trivial but there are complications in computing that you don't get in math

## 2 straight lines

If you run x=[1 2 3] y1=[ 0 1 2] y2=[2 1 0] plot(x,y1,x,y2) you'll see that the lines cross at x=2, y=1. Using maths we could
• Find eq of lines and solve x-y=1 -x+y=2
• x(y1-y2==0) - good because it can find lots of points. x=1:10 y1=4+(-1).^x y2=ones(1,10)*5 plot(x,y1,x,y2) x(y1-y2==0) prints the x values where the y values are the same

## Problem 3: intersection not at a datapoint

x=1:10 y1=sin(x) y2=cos(x) plot(x,y1,x,y2) You'll see that the lines clearly cross twice, but they don't cross at one of the plotted points, so y1-y2 is never 0. We need to interpolate the values, but to do that we need to make assumptions about the nature of the data - should the points ... be connected by straight lines or curves? If curves, what type? In general the data's likely to come from an experiment. If the 2 sets of data don't share the same same of xcoordinates there are further complications.