I have this simple code that creates 3 matrices and plots them:
Y=matrix(c(1,2,3,4), nrow=1)
X1=matrix(c(2,3,3.5,4.5))
X2=matrix(c(0.1, 0.2, 0.6, 1.1), nrow=1)
#Plotting
plot(X1, Y)+lines(X1,Y)
par(new=TRUE)
plot(X2, Y)+lines(X2,Y) + abline(v=0.4, col="red")
Now, I want for the X
value 0.4
to get all the Y
values. The Y values are the values where the red line crosses the other two lines.
So there should be two values, one value Y1
for one line and the other Y2
value for the other line.
Is there maybe any function that I could use to do this? I would really appreciate any suggestion how to do this.