f1=[5000 10000 20000 40000 100000 150000 200000 400000 500000];
f=5000:5000:500000;d=5000;
r1=[268 268 269  271 282 295 312 390 425];
l1=10^(-6).*[680 678 675 669 650 642 635 619 608];
%c5=polyfit(f1,r1,3);

%c15=polyfit(f1,l1,3);
%r=polyval(c5,f);
%l=polyval(c15,f);
r=spline(f1,r1,f);
l=spline(f1,l1,f);
c=10^(-9)*45.5.*ones(size(f));
g=zeros(size(f));z1=zeros(size(f));y=zeros(size(f));d1=4*.3048; d5=4*.3048;%ultima portiune;
for k=1:length(f);
z1(k)=r(k)+2*pi*f(k)*l(k)*i;
y(k)=g(k)+2*pi*f(k)*c(k)*i;
zc(k)=sqrt(z1(k)/y(k));
gamma(k)=sqrt(z1(k)*y(k));
alfa(k)=real(gamma(k));
beta(k)=imag(gamma(k));
 B(k)=zc(k)*sinh(gamma(k)*d1);
B5(k)=zc(k)*sinh(gamma(k)*d5);

A(k)=cosh(gamma(k)*d1);
A5(k)=cosh(gamma(k)*d5);
D5(k)=A5(k);
D(k)=A(k);
C(k)=(1/zc(k))*sinh(gamma(k)*d1);
C5(k)=(1/zc(k))*sinh(gamma(k)*d5);

e(k)=A(k)*D(k)-B(k)*C(k);

end
f11=[1000  5000 10000 50000  100000 150000 300000  500000];
f=5000:5000:500000;
r11=(1/1.6093).*[277.2 277.5 278  286.8 308.4 337.2 431.6 541.7];
l11=(1/1.6093)*10^(-3).*[.986 .984 .982 .958 .935 .920 .888 .857];
g11=(1/1.6093)*10^(-6).*[.115 .466 .853 3.458 6.32 8.993 16.44  25.633];
%c5=polyfit(f1,r1,3);

%c15=polyfit(f1,l1,3);
%r=polyval(c5,f);
%l=polyval(c15,f);
r2=spline(f11,r11,f);
l2=spline(f11,l11,f);
g2=spline(f11,g11,f);
c2=(1/1.6093)*10^(-9)*83.*ones(size(f));
%g=zeros(size(f));

z11=zeros(size(f));y=zeros(size(f)); d2=.0002;%portiunea cu d=.5mm;
d3=.3048*.5;%prima derivatie;
d4=.3048*.5;%a 2-a derivatie;
for k=1:length(f);
z11(k)=r2(k)+2*pi*f(k)*l2(k)*i;
y2(k)=g2(k)+2*pi*f(k)*c2(k)*i;
zc2(k)=sqrt(z11(k)/y2(k));
gamma2(k)=sqrt(z11(k)*y2(k));
%for k=1:length(f);
B2(k)=zc2(k)*sinh(gamma2(k)*d2);
A2(k)=cosh(gamma2(k)*d2);
D2(k)=A2(k);
C2(k)=(1/zc2(k))*sinh(gamma2(k)*d2);
e2(k)=A2(k)*D2(k)-B2(k)*C2(k);
end
for k=1:length(f);
zg(k)=zc(k)*cosh(gamma(k)*d3)/sinh(gamma(k)*d3);
zg2(k)=zc(k)*cosh(gamma(k)*d4)/sinh(gamma(k)*d4);
mod(k)=abs(zg(k));fi(k)=angle(zg(k));xr(k)=mod(k)*cos(fi(k));
yi(k)=mod(k)*sin(fi(k));
end
m1=ones(2,2);
m2=ones(2,2);
m3=ones(2,2);
m4=ones(2,2);
m5=ones(2,2);
m6=ones(2,2);
m7=ones(2,2);
rr=135;hc3=ones(size(f));
for k=1:length(f);
m1=[1 135;0 1];
m2=[A(k) B(k);C(k) D(k)];
m3=[1 0;1/zg(k) 1];
m4=[A2(k) B2(k);C2(k) D(k)];
m6=[1 0;1/zg2(k) 1];
m7=[A5(k) B5(k);C5(k) D5(k)];
m5=m1*m3*m2*m4*m7*m6;
hc(k)= rr/(m5(1,1)*rr+m5(1,2));
hc3(k)=(abs(hc(k)))^2;
end
semilogy(f,hc3)
beta=10^(-13);
for n=1:k
%hc(n)=exp(-alfa(o)*f(n)^.5);
hx(n)=beta*f(n)^1.5;
end
cap=0;
for n=1:k
cap= cap+d*log2(1+hc3(n)/(hx(n)));
end
