Code covered by the BSD License  

Highlights from
Using S-Parameters in MATLAB & Simulink

image thumbnail
from Using S-Parameters in MATLAB & Simulink by Dick Benson
Example of rf amplifier design using S parameters in both MATLAB and Simulink.

simple_smith(In1,In2,Zo,Pos)
function hout = simple_smith(In1,In2,Zo,Pos) 
% function hout = simple_smith(In1,In2,Zo,Pos)
% 
%    In1 = [rvalues];
%    In2 = [xvalues];
%    Zo of line 
%    position 
% Copywrite 2002-2010 The MathWorks, Inc. 
% Required by the powers that be. 
% A tweaked version of an old ML Central submission        

        NumSeg = 50;
        hout=axes('Units','pixels','position',Pos,'box','off','xgrid','off','ygrid','off','zgrid','off',...
                     'color','none','nextplot','add','visible','off');
        set(hout,'xlim',[-1.1 1.1],'ylim',[-1.1,1.1]);
        xlabel('');
        ylabel('');
        theta = linspace(-pi, pi, NumSeg);
        
        for r=(In1)
           z     =((r/(r+1) + 1/(r+1)*exp(j*theta)));
           line('xdata',real(z),'ydata',imag(z),'color',[0.5 0.5 0]);
           xpos = (r-1)/(r+1);
          
           h=text(xpos, 0, sprintf('%2.0f',r*Zo));
           set(h, 'VerticalAlignment', 'top', 'HorizontalAlignment', 'right','color',[1 1 1]);
        end;
        % draw unit circle , and imag==0 line 
        z = exp(j*theta);
        line('xdata',real(z),'ydata',imag(z),'color',[1 1 0]);
        line('xdata',[-1 1],'ydata',[0 0],'color',[1 1 0]);
        v = linspace(0,10,NumSeg);
        r = [ 0 v.^2];
        for x = In2
            z = r+j*x*ones(1,NumSeg+1);
            g = (z-1)./(z+1);
            line('xdata',real(g),'ydata', imag(g), 'color',[0 0.5 0.5]);
            line('xdata',real(g),'ydata',-imag(g), 'color',[0 0.5 0.5]);
            g= ((j*x-1)/(j*x+1));
            xpos = real(g);
            ypos = imag(g);
            s = sprintf('%2.0f',x*Zo);
            h=text([xpos xpos], [ypos -ypos], [' j' s ; '-j' s]);
            set(h(1),'VerticalAlignment', 'bottom','color',[1 1 1]);
            set(h(2),'VerticalAlignment', 'top','color',[1 1 1]);
            if xpos == 0 
               set(h, 'Horizontalalignment', 'center');
            elseif xpos < 0
               set(h, 'Horizontalalignment', 'right');
            end
        end;
        rmin = min(In2);
        rmax = max(In2);
        line('xdata',[(rmin-1)/(rmin+1),(rmax-1)/(rmax+1)],'ydata',[0 0],'color',[1 1 0]);

 



Contact us at files@mathworks.com