From B-parameters to S-parameters
In matrix form, the formula is
S=([0k20Z2k2]B+[k10−Z1k10])([0k20−Z2k2]B+[k10Z1k10])−1
While for each element, we obtain
S11S12S21S22=B12−B11Z1−B22Z2+B21Z1Z2B12+B11Z1−B22Z2−B21Z1Z2=−k2(B12−B11Z1−B22Z2+B21Z1Z2)2Z1k1=−k1(B12−B11Z1−B22Z2+B21Z1Z2)2Z2k2(B11B22−B12B21)=B12−B11Z1−B22Z2+B21Z1Z2B12−B11Z1+B22Z2−B21Z1Z2
The formulas are obtained with the methods explained here.
The MATLAB implementation can be found in circuitconversions on Gitlab.
Definitions
[V2−I2]=B[V1I1] | [B1B2]=S[A1A2] |
The incident and reflected waves are defined as
A1A2=k1(V1+I1Z1)B1=k2(V2+I2Z2)B2=k1(V1−I1Z1)=k2(V2−I2Z2)
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.