From Y-parameters to Z-parameters
In matrix form, the formula is
Z=Y−1
When dealing with 2 ports, we obtain
Z11Z12Z21Z22=Y11Y22−Y12Y21Y22=−Y11Y22−Y12Y21Y12=−Y11Y22−Y12Y21Y21=Y11Y22−Y12Y21Y11
The formulas are obtained with the methods explained here.
The MATLAB implementation can be found in circuitconversions on Gitlab.
Definitions
II1⋮IN=YVV1⋮VN | VV1⋮VN=ZII1⋮IN |