function Z=rpatch1(f,wp,lp,h,Zc,ereff)

%f ... frequency [Hz]
%wp ... width of patch [m]
%lp ... length of path [m]
%h ... substrate height [m]
%ereff ... substrate realtive permitivitty
%Zc ... characteristic impedance of the line (width W)

% rpatch1(10e9,0.015,0.0096,0.00157,21.5,2.27)


a=wp;b=lp;					%substitution


mi0=4*pi*1e-7;epsilon0=8.854*1e-12;
c=1/sqrt(mi0*epsilon0);
N=size(f,2);
lambda0=c*ones(1,N)./f;k0=2*pi*ones(1,N)./lambda0;
Z0=sqrt(mi0/epsilon0);


%Y0=a*sqrt(er)/(h*Z0);	%tran. line admit. for the patch
ws=h;			%width of the radiating slot is supposed to be
			%equal to the width of the patch

Y1=pi*a*(1+j*(ones(1,N)-log(2)*log(k0*ws)))./(lambda0*Z0);

Z1=ones(1,N)./Y1;


beta=k0*sqrt(ereff);				%phase constant [rad/m]

ro2=(Z1-Zc)./(Z1+Zc);			%reflection coeff. at the end of 
										%the patch
ro1=ro2.*exp(-j*2*beta*b);		%and on input port

Z1T=Zc*(1+ro1)./(1-ro1);
Y1T=ones(1,N)./Z1T;				%Transformed slot admitance
Ytotal=Y1+Y1T;						%Total patch admitance
Z=ones(1,N)./Ytotal;
