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.

s_extract(file_name,fmin,fmax,df)
function [sout,fout] = s_extract(file_name,fmin,fmax,df)
% This converts the measurement data from its dB - Phase format to a 
% complex (x + j*y) format. 
% Copywrite 2002-2010 The MathWorks, Inc. 
       d=load(file_name,'-mat');
       f=d.data.s(1,1).freq;
       
       n = sum(fmin>=f);       % low freq index
       m = sum(f<fmax);       % high freq index
       inc = round(df/(f(2)-f(1)));
       if inc >0
          fout = f(n:inc:m);
          v = n:inc:m;
      else
          fout =f(n);
          v = n;
      end;
       for k =1:2
           for l=1:2
                [x,y]      = dbphase2xy(d.data.s(k,l).mag(v),d.data.s(k,l).ph(v));
                sout(k,l).s= x+j*y;
           end;
       end;

Contact us