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.

make_model.m
% The S parameter values measured with the 8505A can easily be exported to
% any design environment. This script exports the parameters to a file which 
% can be read by the Eagleware Super Star RF design program. 
% Copywrite 2002-2010 The MathWorks, Inc. 
target_file = 'mrf904.a10';     % this is the 8505 file to be read and converted

fmin = 10;                      % low freq limit in MHz
fmax = 1300;                    % upper freq limit in MHz
df = 50;                        % freq increment in MHz. 
[st,fvec] = s_extract('mrf904_10_10a.rfa',fmin,fmax,df);   % data now in MATLAB .... 

fid = fopen(target_file,'wt+'); % open a text file for output 
   
L = length(fvec);
for p = 1:L
  f = fvec(p);
  for m= 1:2
      for n= 1:2
         [mag(m,n),phase(m,n)]=cmplx2magphase(st(m,n).s(p));
     end;
  end;
  % save it to the output file in ascii compatible format for Super Star
  % application. 
  fprintf(fid,' %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f  \n  ', f, mag(1,1),phase(1,1),mag(2,1),phase(2,1),mag(1,2),phase(1,2),mag(2,2),phase(2,2));
 
end;
fclose(fid); % close the output file.
clc
disp(['Data conversion complete to ', target_file,' Super Star compatible file.',char(13)])

Contact us