function [r,zin] = tl(f,c1,d1,z1,zm)
% TL(f,c1,d1,z1,zm) is transmission line function
% returns a pressure or voltage ratio r and input impedance zin
% from inputs f (frequency Hz),c1 (line sound speed m/s),
% d1 (line length meters),z1 line impedance (MRayl or ohms)
% zm load impedance (MRayl or ohms)
% T. L. Szabo July 2004 Diagnostic Ultrasound Imaging: Inside Out
gam=2*pi*f*d1/c1;  %create argument 
ng=size(gam);      % determine size of array gam
zmarray=zm*ones(ng); % create zm array
r=zmarray./(zm*cos(gam)-i*z1*sin(gam));% ratio:pressure p2/p1 or voltage v2/v1
% calculate zin
zin=z1*(zm*cos(gam)-i*z1*sin(gam))./(-i*zm*sin(gam)+z1*cos(gam)); 


