function y_params = z2y(z_params)
%Z2Y Convert Z-parameters to Y-parameters
%   Y_PARAMS = Z2Y(Z_PARAMS) converts the impedance parameters Z_PARAMS
%   into the admittance parameters Y_PARAMS.
%
%   Z_PARAMS is a complex NxNxM array of M N-port Z-parameters. The output
%   Y_PARAMS is a complex NxNxM array of M N-port Y-parameters.
%
%   See also Y2Z, Z2S, Z2H, Z2ABCD, S2Y, H2Y, ABCD2Y

%   Copyright 2003-2023 The MathWorks, Inc.

arguments
    z_params {mustBeNumeric,mustBeNonempty,mustBeNonNan, ...
        rf.internal.mustBeVectorOrNxNxM}
end
if isvector(z_params)
    z_params = reshape(z_params,1,1,[]);
end

% Calculate the Y-parameters
y_params = pageinv(z_params);
