function z_params = y2z(y_params)
%Y2Z Convert Y-parameters to Z-parameters
%   Z_PARAMS = Y2Z(Y_PARAMS) converts the admittance parameters Y_PARAMS
%   into the impedance parameters Z_PARAMS.
%
%   Y_PARAMS is a complex NxNxM array of M N-port Y-parameters. The output
%   Z_PARAMS is a complex NxNxM array of M N-port Z-parameters.
%
%   See also Z2Y, Y2S, Y2H, Y2ABCD, Z2S, H2Z, ABCD2Z

%   Copyright 2003-2023 The MathWorks, Inc.

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

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