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
tudor dima (2020). S-parameter toolbox (+ Z, Y, H, G, ABCD, T) (https://www.mathworks.com/matlabcentral/fileexchange/6080-s-parameter-toolbox-z-y-h-g-abcd-t), MATLAB Central File Exchange. Retrieved .
It works for my need. Thank you.
Hi, excellent, thanks.
I would suggest adding the option allowing the user to specify the normalization impedance(s) of the Spar and work with unnormalized data.
very thank you!!!! this function works well and help me to solve many problems!
This is fantastic work. It runs perfectly without errors :)
Thanks. It definitely saved me some time.
thank u for this file
Thanks, really helpful.
I am not sure I understand the question. The S-parameters are stored as 3D matrices, with the last index spanning the frequency. An N-port at F frequencies will have the size [N N F], that is NxNxF, where N=2 for this 2-port case.
what is meant by 2x2xM matrix? how to write it in matlab?
It shouldn't... (uses str2num or str2double...)
anyway, could you send me a sample file so I can take a look at it?
I'm finding an issue with SXPWrite.
It does not support or properly truncate scientific notation- a number like -9.8235e-5 ends up being written to the file like -9.8235. This is a HUGE problem! Otherwise a great set of tools.
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));
Thank you for saving me from having to write an S2P parser! Truly appreciate it!
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.
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.
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(:)))
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
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
to read s2p files without noise data, change line 135 in SXPParse.m to 'while flagNoiseStarted && flagGotOptions'.
great, thanks; suggestions : smith chart ? circles ?
very good; if it had plots it would completely replace my viewer
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.
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.
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.
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 !
nifty ! I like the file import/export operations
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 !
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
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
- added 3rd dimension (frequency)
more separators allowed, file read speed improvement, better code flow
SXPParse revision : v.1.4, 2008.10.25
- bug fixed in 'db' format conversion
re-included Phrase2Word.m (previously left out by error); unless you had unzipped over an older version the file parsing would not work;
modified SXPParse.m in order to handle Z,G,Y,ABCD data, and also comment lines anywhere inside data file
added limited octave compatibility : s2a, a2s, y2s, SXPRead
added 3rd dimension (multiple frequencies) for z2a, y2a