%% 線路のZ行列
z0=50.;
beta=300.;
len=10.;
z_mat=[1 2;
       3 4];
   
%% Z行列⇒S行列への変換
z_mat
z_to_s(z_mat)
s_to_z(z_to_s(z_mat))

%% %%%%%%%% 関数定義 %%%%%%%%
% Z行列⇒S行列への変換
function s = z_to_s(z)
    z0=50.;
    z1=150.;
    v=[1/sqrt(z0) 0; 0 1/sqrt(z1)];
    s=inv(v*z*v+eye(2))*(v*z*v-eye(2));
end
% S行列⇒Z行列への変換
function z = s_to_z(s)
    z0=50.;
    z1=150.;
    u=[sqrt(z0) 0; 0 sqrt(z1)];
    z=u*(eye(2)+s)*inv(eye(2)-s)*u;
end