function smith
% SMITH    Draws a Smith chart and sets hold to on so that you can plot the
%          reflection coefficient on top of it.

% This is a quick little hack that draws a simple Smith chart, a diagram
% that is very frequently used in high frequency engineering.  It maps
% the normalized impedance z to the reflection coefficient gamma:
% gamma = (z-1)/(z+1)  with z = r+i*x .

% You can customize the function by specifying the r=const and x=const lines
% you want to draw at the beginning of the corresponding loops.

% 3-13-95   Frank Wiedmann   wiedmann@com.enst.fr


plot([-1 1],[0 0],'w')

axis equal
axis off

hold on

tr = 2*pi*(0:.01:1);
for r = [0 .2 .5 1 2 5]   % specify the r=const lines you want to draw
   rr = 1/(r+1);
   cr = 1-rr;
   plot(cr+rr*cos(tr),rr*sin(tr),'w')
end

for x = [.2 .5 1 2 5]     % specify the x=const lines you want to draw
   rx = 1/x;
   cx = rx;
   tx = 2*atan(x)*(0:.01:1);
   plot(1-rx*sin(tx),cx-rx*cos(tx),'w')
   plot(1-rx*sin(tx),-cx+rx*cos(tx),'w')
end
