From S-parameters to Z-parameters
In matrix form, the formula is
Z=K−1(IN+S)(IN−S)−1KZ0
When dealing with 2 ports, we obtain
Z11Z12Z21Z22=−S11+S22−S11S22+S12S21−1Z1(S11−S22−S11S22+S12S21+1)=−k1(S11+S22−S11S22+S12S21−1)2S12Z2k2=−k2(S11+S22−S11S22+S12S21−1)2S21Z1k1=−S11+S22−S11S22+S12S21−1Z2(S22−S11−S11S22+S12S21+1)
The formulas are obtained with the methods explained here.
The MATLAB implementation can be found in circuitconversions on Gitlab.
Definitions
BB1⋮BN=SAA1⋮AN | VV1⋮VN=ZII1⋮IN |
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.