clear; clc
% input values
% the impedances are in ohms
Z1=50; Z2=-j*50; Z3=-j*50; Z4=j*100; Z5=j*100; Z6=50;
% the currents are in amperes
% current i01:
i01max=0.2; i01angle=0; % angle in degrees
% complex representation of the current i01
I01=i01max*exp(j*i01angle*pi/180);
% incidence matrix A
A=[-1  1  0  1  0  0;
    0 -1  1  0  1  0;
    0  0 -1 -1  0  1];
% column matrix I0
I0=[I01; 0; 0; 0; 0; 0];
% diagonal matrix Y
Y=diag([1/Z1 1/Z2 1/Z3 1/Z4 1/Z5 1/Z6]);
I0k=A*I0;
Yk=A*Y*A';
Uk=-inv(Yk)*I0k;
U=A'*Uk
Zin=Uk(1)/(I01-Uk(1)/Z1)
U6=Uk(3)
Ku=U6/(Z1*I01)