That looks like something I wrote!
It would be helpful to know the context (I don’t remember where I posted it), however it appears that ‘x1’ and ‘x2’ are vectors spanning different ranges. The ‘x’ assignment produces a vector that spans both ranges, The ‘y1’ and ‘y2’ assignments interpolate and extrapolate the original ‘y1’ and ‘y2’ to the new ‘x’, and the ‘index’ assignment returns the approximate intersection indices of ‘y1’ and ‘y2’. The loop then interpolates first to find the accurate ‘x’ value of the intersection (as ‘xi’), and then uses that value to interpolate the accurate ‘y’ value of the intersection (as ‘yi’). The ‘indexrange’ vector are the indices of both vectors for the interpolation, and is constructed so that the first value is never less than 1 and the last value is never greater than the length of the vector. The ‘Xc’ matrix concatenates them so that ‘xi’ is the first row and ‘yi’ is the second row. This simply makes it easier to view the result of the loop.
I usually comment-document my code, so my apologies if I forgot to in that instance.