4.9375

4.9 | 16 ratings Rate this file 69 Downloads (last 30 days) File Size: 24.44 KB File ID: #6080

S-parameter toolbox (+ Z, Y, H, G, ABCD, T)

by tudor dima

 

20 Oct 2004 (Updated 30 Sep 2011)

Convert between N-port representations of RF circuits. Read / Write industry-standard files.

| Watch this File

File Information
Description

Useful for the RF designer, it manipulates the various complex representations of the circuits as multi-ports, namely conversions from one representation to another as well as reading/writing from/to files in industry-standard format.
 
The (more oftenly used) transformations are singularity-protected; some legacy stuff could be done better today... and it is slowly getting done :-)!

The file parsing/writing in particular has been greatly improved thanks to the input received from the users on this site.

I hope this toolbox will help you when searching for that elusive insight when working at high frequencies !

Have fun !

p.s. any ideas ? bugs ? email me

Acknowledgements
This submission has inspired the following:
Coupling Coefficient K For a Resonator Filter
MATLAB release MATLAB 7.6 (R2008a)
Other requirements none; it's strictly numeric so it should work on any matlab version supporting N-size arrays (newer than 5.1?); still, I preserved the some alternate functions (2-D arrays only) which should work on 3.x versions
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (22)
27 Oct 2004 al davidson

excellent so far (I have only used the conversion to and from s-parameters); I like especially converting to ABCD or T parameters, this way you can do cascaded simulations

30 Mar 2005 charles beam

yes, cascaded simulations will work just fine if you know how to write the individual s-matrices; I hope this will be included in a later release

03 Jun 2005 wayne sho

it's pretty cool; I like the fact that it's simple and doesn't need 1G of RAM; btw, yes, I tried it in 4.2, it works !

03 Jul 2006 george ardeleanu

nifty ! I like the file import/export operations

09 Oct 2006 yin chow

Excellent ! we are a few RF designers sharing a single licence of mwoffice and since using this toolbox everything goes smoother - I can get 50-75% of the work done before I fire up the simulator to refine my design. Thanks !

02 May 2007 bahareh siasi

the program is exellent but SXPparse function has a problem,once reading the snp file for more than 4 ports(when the sparameter of a frequency is written in more than one single line )the program brakes.

17 May 2007 jonathan cape

very good ! ...and very fast :-)

I like especially the singularity-protection, is saves me a lot of hassle from defining quasi-perfect shorts or opens.

BTW, I did not find any files that the parser won't work with. Mind you, we use only HP/Agilent, which is among the orginators of the standard.

20 May 2007 Jeff P

I wanted to use this to read Agilent PNA .s2p files. However, the sxpparse.m function makes a call to phrase2word.m, which is not included in the toolbox. I found this function on the Exchange. Now, sxpparse hangs up trying to parse the first line of numerical data. The code does not appear to handle cell arrays well. Anyway, it was easier to write my own function than to debug this one.

12 Oct 2007 rajeeh akbar

very good; if it had plots it would completely replace my viewer

29 Nov 2007 leonard cristovski

great, thanks; suggestions : smith chart ? circles ?

15 Dec 2007 j hatchatourian  
24 Sep 2008 S Malevsky  
28 Jul 2009 sree kasturi

to read s2p files without noise data, change line 135 in SXPParse.m to 'while flagNoiseStarted && flagGotOptions'.

12 Aug 2009 tudor dima

posted the new version that allows more separators and also improves the file parsing speed

@sree kasturi :
thanks for the observation; however, in the absence of noise data the previous version of the function only executed the following two lines, then jumped to end; anyway, I have meanwhile posted the new version and included your suggestion

25 Jun 2010 Chris

Would this be the right way to calculate the cascaded input/output VSWR?:

% first in cascade
s1 = [148+1.4*1i 193-756*1i; 198-762*1i 119+44*1i]*1e-3;
% second in cascade
s2 = [33+68*1i 724-167*1i; 731-166*1i -22+77*1i]*1e-3;

t1 = s2t(s1);
t2 = s2t(s2);

t = t1*t2;
s = t2s(t);

(1+abs(s(1,1)))/(1-abs(s(1,1))) % input VSWR
(1+abs(s(2,2)))/(1-abs(s(2,2))) % output VSWR

Thanks

12 Jul 2010 tudor dima

@Chris
Yes, that's absolutely right.
One note: in case your data is closer to a singularity (for instance during calibrations when data exhibits extremely low or high return losses) then it's a good practice to doublecheck the above using :

a1 = s2a(s1);
a2 = s2a(s2);
s_12_a = a2s(a1*a2);

and then compare the results; (it was not your case, here the maximum delta is 2.2215e-016 -- using max(abs(s_12_a(:)-s(:)))

13 Aug 2010 Andrew Farris  
14 Dec 2010 Matthew

Thanks Tudor for writing this very handy toolbox, I have been using it for about a year while I am in grad school and it has saved me a lots of time with its robust handling of Touchstone files (much better and faster than the script I wrote myself) and the handling of singularities in network parameter conversion.

One comment, I have made an alternate version of the s2a and a2s functions which take an optional Zo parameter so that you can have non-unit Zo. In this version Bnew=B*Zo and Cnew=C/Zo in s2a, and it simply reverses these factors in a2s. It is easy to do this external to the function for Y and Z parameters since you just multiply or divide by Zo, but a bit messier to do for ABCD parameters. If you like I can send you the files.

21 Dec 2010 tudor dima

@Matthew
Great to hear that!

Sure, please send the files over and I'll have a look; it was about time I did a revision of the whole box.

26 Oct 2011 David Yu-Ting Wu

Thank you for saving me from having to write an S2P parser! Truly appreciate it!

12 Jan 2012 Tao Yi Lee  
12 Jan 2012 Tao Yi Lee

I suggest a minor modification in SXPParse.m for robustness.

At line 55.

% --- find out matrix order ---
    [~, NoOfPorts] = strtok(DataFileName, '.');
    NoOfPorts = strtok(NoOfPorts, 'p');
    NoOfPorts = str2double(NoOfPorts(3:end));

Please login to add a comment or rating.
Updates
22 Feb 2005

added 3rd dimension (multiple frequencies) for z2a, y2a

03 Jun 2005

added limited octave compatibility : s2a, a2s, y2s, SXPRead

09 Mar 2006

modified SXPParse.m in order to handle Z,G,Y,ABCD data, and also comment lines anywhere inside data file

22 Jun 2007

re-included Phrase2Word.m (previously left out by error); unless you had unzipped over an older version the file parsing would not work;

28 Jan 2008

- bug fixed in 'db' format conversion
- better help and better info on MDIF standard

25 Oct 2008

SXPParse revision : v.1.4, 2008.10.25
fix for the case nPort>4 (when lines get split)
allow comments on lines
allow various separators (tabs!)
better parsing, subfunctions introduced
limited protection for non-compliant files

05 Aug 2009

more separators allowed, file read speed improvement, better code flow

30 Sep 2011

- added 3rd dimension (frequency)
  to h2y, y2h, g2y, y2g, h2g,
- faster h2* and *2h conversions
- h2g (and its wrap, g2h) as
  protected inverses

Tag Activity for this File
Tag Applied By Date/Time
wireless tudor dima 22 Oct 2008 07:33:22
s parameters tudor dima 22 Oct 2008 07:33:22
z tudor dima 22 Oct 2008 07:33:22
g tudor dima 22 Oct 2008 07:33:23
h tudor dima 22 Oct 2008 07:33:23
y tudor dima 22 Oct 2008 07:33:23
abcd tudor dima 22 Oct 2008 07:33:23
t tudor dima 22 Oct 2008 07:33:23
snp tudor dima 22 Oct 2008 07:33:23
s2p tudor dima 22 Oct 2008 07:33:23
sxp tudor dima 22 Oct 2008 07:33:23
conversion tudor dima 22 Oct 2008 07:33:23
snp Subby 12 Nov 2008 12:15:13
s2p Jose 28 Nov 2008 08:07:17
sparameters tudor dima 05 Aug 2009 11:39:23
mdif file tudor dima 05 Aug 2009 11:39:23
abcd Gilbert 06 Oct 2009 05:21:41
wireless Gilbert 06 Oct 2009 06:00:43
y Gilbert 06 Oct 2009 06:00:47
sparameters Merrick Moeller 07 Apr 2010 08:47:37
multiport tudor dima 03 Oct 2011 11:54:39
nport tudor dima 03 Oct 2011 11:54:39
rf tudor dima 03 Oct 2011 11:54:39
blackbox tudor dima 03 Oct 2011 11:54:39
s parameters dush 25 Oct 2011 00:05:12
s2p mauro pelosi 02 Nov 2011 07:53:38
abcd Saqib 15 Dec 2011 06:44:32
rf Tao Yi Lee 12 Jan 2012 13:10:48
s2p Tao Yi Lee 12 Jan 2012 13:10:53
snp Tao Yi Lee 12 Jan 2012 13:10:56
abcd Tao Yi Lee 12 Jan 2012 13:10:58
touchstone Tao Yi Lee 12 Jan 2012 13:11:12

Contact us at files@mathworks.com