mt1=mn1/cos(deg2rad(B1));
mt2=mn2/cos(deg2rad(B2));
if mt1*(Zs+Zp1)~=mt1*(Zr1-Zp1)
if mt1*(Zr1-Zp1)~=mt2*(Zr2-Zp2)
P11(i0+1)=(rem(i0*Zp1,np))/np;
P22(i0+1)=(rem(i0*Zp2,np))/np;
if isempty(A_P1)==1 || isempty(A_P2)==1
A_P=zeros(length(A_P1),length(A_P2));
A_P(i,ii)=A_P1(i)==A_P2(ii);
At1=atan(tan(deg2rad(An1))/cos(deg2rad(B1)));
I_At1=tan(At1)-(pi()*At11)/180;
I_Awt1=((2*(Xs+Xp1))/(Zs+Zp1))*tan(deg2rad(An1))+I_At1;
X(i1)=1+(I_Awt1-tan(1)+1)/tan(1)^2;
X(i1)=X(i1-1)+(I_Awt1-tan(X(i1-1))+X(i1-1))/tan(X(i1-1))^2;
ds=(Zs*mn1)/cos(deg2rad(B1));
dp1=(Zp1*mn1)/cos(deg2rad(B1));
dws=dbs/cos(deg2rad(Awt1));
dwp1=dbp1/cos(deg2rad(Awt1));
ysp1=((Zs+Zp1)/(2*cos(deg2rad(B1))))*((cos(At1)/cos(deg2rad(Awt1)))-1);
asp1=((Zs+Zp1)/(2*cos(deg2rad(B1)))+ysp1)*mn1;
alpha_p1=acos(dbp1/dap1);
epsilon_a1=(Zp1/(2*pi()))*(tan(alpha_p1)-tan(deg2rad(Awt1)));
epsilon_a2=(Zs/(2*pi()))*(tan(alpha_s)-tan(deg2rad(Awt1)));
epsilon_a=epsilon_a1^2+epsilon_a2^2-epsilon_a1-epsilon_a2+1;
eta_alpha=1-mu*pi()*((1/Zs)+(1/Zp1))*epsilon_a;
At2=atan(tan(deg2rad(An1))/cos(deg2rad(B1)));
I_At2=tan(At2)-(pi()*At22)/180;
I_Awt2=((2*(Xr1-Xp1))/(Zr1-Zp1))*tan(deg2rad(An1))+I_At2;
Y(i2)=1+(I_Awt2-tan(1)+1)/tan(1)^2;
Y(i2)=Y(i2-1)+(I_Awt2-tan(Y(i2-1))+Y(i2-1))/tan(Y(i2-1))^2;
dp11=(Zp1*mn1)/cos(deg2rad(B1));
dr1=(Zr1*mn1)/cos(deg2rad(B1));
dwp11=dbp11/cos(deg2rad(Awt2));
dwr1=dbr1/cos(deg2rad(Awt2));
yp1r1=((Zr1-Zp1)/(2*cos(deg2rad(B1))))*((cos(At2)/cos(deg2rad(Awt2)))-1);
ap1r1=((Zr1-Zp1)/(2*cos(deg2rad(B1)))+yp1r1)*mn1;
alpha_p11=acos(dbp11/dap11);
alpha_r1=acos(dbr1/dar1);
epsilon_b1=-(Zr1/(2*pi()))*(tan(alpha_r1)-tan(deg2rad(Awt2)));
epsilon_b2=(Zp1/(2*pi()))*(tan(alpha_p11)-tan(deg2rad(Awt2)));
epsilon_b=epsilon_b1^2+epsilon_b2^2-epsilon_b1-epsilon_b2+1;
eta_beta=1-mu*pi()*((1/Zp1)-(1/Zr1))*epsilon_b;
At3=atan(tan(deg2rad(An2))/cos(deg2rad(B2)));
I_At3=tan(At3)-(pi()*At33)/180;
I_Awt3=((2*(Xr2-Xp2))/(Zr2-Zp2))*tan(deg2rad(An2))+I_At3;
Z(i3)=1+(I_Awt3-tan(1)+1)/tan(1)^2;
Z(i3)=Z(i3-1)+(I_Awt3-tan(Z(i3-1))+Z(i3-1))/tan(Z(i3-1))^2;
dp2=(Zp2*mn2)/cos(deg2rad(B2));
dr2=(Zr2*mn2)/cos(deg2rad(B2));
dwp2=dbp2/cos(deg2rad(Awt3));
dwr2=dbr2/cos(deg2rad(Awt3));
yp2r2=((Zr2-Zp2)/(2*cos(deg2rad(B2))))*((cos(At3)/cos(deg2rad(Awt3)))-1);
ap2r2=((Zr2-Zp2)/(2*cos(deg2rad(B2)))+yp2r2)*mn2;
alpha_p2=acos(dbp2/dap2);
alpha_r2=acos(dbr2/dar2);
epsilon_g1=-(Zr2/(2*pi()))*(tan(alpha_r2)-tan(deg2rad(Awt3)));
epsilon_g2=(Zp2/(2*pi()))*(tan(alpha_p2)-tan(deg2rad(Awt3)));
epsilon_g=epsilon_g1^2+epsilon_g2^2-epsilon_g1-epsilon_g2+1;
eta_gamma=1-mu*pi()*((1/Zp2)-(1/Zr2))*epsilon_g;
eta=((1-I2)/(1+I1))*((1+(eta_alpha*eta_beta*I1))/(1-(eta_beta*eta_gamma*I2)));
eta_gyaku=((1+I1)/(1-I2))*((eta_alpha*(eta_beta*eta_gamma-I2))/(eta_gamma*(eta_alpha*eta_beta+I1)));
eta=((1-I2)/(1+I1))*((eta_gamma*(eta_beta+eta_alpha*I1))/(eta_beta*eta_gamma-I2));
eta_gyaku=((1+I1)/(1-I2))*((eta_alpha*(1-eta_beta*eta_gamma*I2))/(eta_alpha+eta_beta*I1));
if isreal(eta) == 0 || isreal(eta_gyaku) == 0
if dap1/(asp1*sin(pi()/n))>=2
if dap2/(asp1*sin(pi()/n))>=2
if epsilon_a1+epsilon_a2<epsilon_l
if epsilon_b1+epsilon_b2<epsilon_l
if epsilon_g1+epsilon_g2<epsilon_l
inv1=Zp1/((1-(tan(alpha_r1)/tan(deg2rad(Awt2))))*Zr1);
inv2=Zp2/((1-(tan(alpha_r2)/tan(deg2rad(Awt3))))*Zr2);
sita_p1=acos(((dar1/2)^2-(dap11/2)^2-ap1r1^2)/2/ap1r1/(dap11/2))+tan(alpha_p11)-alpha_p11-I_Awt2;
sita_r1=acos((ap1r1^2+(dar1/2)^2-(dap11/2)^2)/2/ap1r1/(dar1/2));
sita_p2=acos(((dar2/2)^2-(dap2/2)^2-ap2r2^2)/2/ap2r2/(dap2/2))+tan(alpha_p2)-alpha_p2-I_Awt3;
sita_r2=acos((ap2r2^2+(dar2/2)^2-(dap2/2)^2)/2/ap2r2/(dar2/2));
tro1=sita_p1*(Zp1/Zr1)+I_Awt2-(tan(alpha_r1)-(pi()*rad2deg(alpha_r1))/180);
tro2=sita_p2*(Zp2/Zr2)+I_Awt3-(tan(alpha_r2)-(pi()*rad2deg(alpha_r2))/180);
Answer(K,:)=[Zs Zp1 Zr1 Zp2 Zr2 mn1 mn2 g eta eta_gyaku];