MATLAB: Intersection between two curved lines

curved linesintersection

Hello I need a help with finding intersection point on Y-axis between two curved lines on the picture below.
Below is the code Im runnig to generate the points for these lines, if it helps
%Generovanie bodov noža
clc
rn = 1.3;
f = 0.5;
ap = 0.2;
po = 10;
dx = 0.01;
lambda = 0;
gamma = -8;
Kr = 51;
Kr1 = 51;
xa = (rn*(sin(Kr)))*-1;
xb = rn*(sin(Kr1));
ya = (xa*(tan(Kr)))+(rn/(cos(Kr)))-rn;
%priamka A
N = 92
xpA = xa - (0:N-1)*dx;
xpA = xpA';
xpA = sort(xpA);
xpA = round(xpA,2);
ypA = (xpA*tan(Kr))+(rn/(cos(Kr)))-rn;
ypA1 = sort(ypA);
ypA1 = round(ypA,2);
%priamka B
xpB = xb + (0:N-1)*dx;
xpB = xpB';
xpB = round(xpB,2);
ypB = (-xpB*tan(Kr1))+(rn/(cos(Kr1)))-rn;
ypB = round(ypB,2);
%kruznica
N1 = 500;
xk1 = xa + (1:N1)*dx;
xk1 = round(xk1,2);
xk1 = xk1';
[c,d]= intersect(xk1,min(xpB))
xk = xa +(1:d-1)*dx;
xk = round(xk,2);
xk = xk';
yk = (sqrt((rn^2)-(xk.^2)))-rn;
yk = round(yk,2);
X = [xpA;xk;xpB];
Y = [ypA;yk;ypB];
b = po-ap;
x = X(1);
X1 = X-x;
Y1 = Y+b;
X2 = X1+f;
Y2 = Y1;
plot(X1,Y1)
hold on
plot(X2,Y1)

Best Answer

The part of the code after
X = [xpA;xk;xpB];
Y = [ypA;yk;ypB];
changes to:
b = po-ap;
x = X(1);
X1 = X-x;
Y1 = Y+b;
X2 = X1+f;
Y2 = Y1;
[Y1max,Y1ix] = max(Y1);
[Y2max,Y2ix] = max(Y2);
Xi = linspace(min([X1(Y1ix);X2(Y2ix)]), max([X1(Y1ix);X2(Y2ix)]), 20);
Y1i = interp1(X1,Y1,Xi);
Y2i = interp1(X2,Y2,Xi);
Ydif = sort(Y2i-Y1i);
Xq = interp1(Ydif, Xi, 0);
Yq = interp1(Xi, Y1i, Xq);
figure
plot(X1,Y1)
hold on
plot(X2,Y1)
plot(Xq, Yq, 'sg', 'MarkerSize', 10)
hold off
text(Xq, Yq, sprintf('\\uparrow\nX = %.4f\nY = %.4f',Xq,Yq), 'HorizontalAlignment','center', 'VerticalAlignment','top')
producing:
.