MATLAB: How to plot loop array against equations (Equations not intersecting if placed in a array for-loop)- see the image attached

graphicalintersectionMATLAB

I need to graphically obtain two equation intersection on a array vector and store it for plotting. I have achieved the plot but the intersection is not at the required place and doesn't match the analysis on my paper. There is something which i am missing out. the last code in the script indicates on the plot where the equations must meet as per the anaylsis i did on paper and the image attached.
the equation is for Ki, Lambda with a delay plant
clear all; close all; clf; clc
tc2=0.4; %Time constant value
delay2=0.01; %Delay
wc=10;
phasemargin=50;
h=1;
for lambda=0:0.001:2;
%Equation 1
t=tan(atan(wc*tc2)+phasemargin+delay2*wc);
M=(((wc^(-lambda))*(sin((lambda*pi)/2)))+((wc^(-lambda))*(cos((lambda*pi)/2)*t)));
ki(h)=-t/M; %Equation 1
%Quadratic Equation 2
A=(tc2/(1+((wc*tc2)^2)))+delay2;
B=2*A*(wc^(-lambda))*cos((lambda*pi)/2)-(lambda*(wc^(-lambda-1))*sin((lambda*pi)/2));
a=A; b=B; c=wc^(-2*lambda);
ki1(h)= (-b+sqrt(b^2-4*(a^2)*c))/(2*a*c); %Equation 2
lms(h)=lambda;
h=h+1;
end
figure(1);
plot(lms,ki,'r', 'Linewidth',1);hold on
plot(lms,ki1,'k-','Linewidth',1);hold on;
%this codes will tell where the equation must intersect.
plot(0.8731,11.059,'ro', 'MarkerSize', 10)
axis([0 2.5 -5 15])
If I remove the lambda array from lambda 0:0.001:2 and place lambda=0.8731 then ki=11.059 is the output similar to the graph i want to obtain.
Please help me identify and obtain the graph at the intersection on the red circle for lambda and Ki values.
Thank you!

Best Answer

solution at lambda = -2
solution at lambda approx -.9815995068,
solution at lambda = 0
singularity at lambda = 2*(-arctan(sin(arctan(4)+501/10)/cos(arctan(4)+501/10))/Pi + 2*Z where Z is any integer. In particular, when Z = 1, the singularity is at approximately 1.261307667
solution at lambda approx 1.397492768
solution at lambda = 2
Between 0 (exclusive) and approximately 0.8505376836, ki1 has a non-zero imaginary component. The intersection you mark, at about 0.8731, ki and ki1 have opposite signs, and the signs stay opposite until the singularity noted above
so given those equations and constants, ki and ki1 cannot be equal near 0.8731