From Z-parameters to S-parameters
In matrix form, the formula is
S=K(Z−Z0)(Z+Z0)−1K−1
When dealing with 2 ports, we obtain
S11S12S21S22=−Z11Z22−Z12Z21+Z11Z2+Z22Z1+Z1Z2Z12Z21−Z11Z22−Z11Z2+Z22Z1+Z1Z2=k2(Z11Z22−Z12Z21+Z11Z2+Z22Z1+Z1Z2)2Z12Z1k1=k1(Z11Z22−Z12Z21+Z11Z2+Z22Z1+Z1Z2)2Z21Z2k2=−Z11Z22−Z12Z21+Z11Z2+Z22Z1+Z1Z2Z12Z21−Z11Z22+Z11Z2−Z22Z1+Z1Z2
The formulas are obtained with the methods explained here.
The MATLAB implementation can be found in circuitconversions on Gitlab.
Definitions
VV1⋮VN=ZII1⋮IN | BB1⋮BN=SAA1⋮AN |
The incident and reflected waves are defined as
A=K(V+Z0I)B=K(V−Z0I)
where K and Z0 are defined as
K=k1⋱kNZ0=Z0,1⋱Z0,N
with Z0,i the reference impedance for port i and ki defined as
ki=2ℜ(Z0,i)1ki=α2∣Z0,i∣ℜ(Z0,i)
depending on whether you are using power- or pseudowaves.