This code takes the input of the Y1 matrix and the initial impedance to produce a vector of v1 values, using equations discovered in previous research. This code also produces v2 as well as yin which is not needed for our purposes.
%function to produce values for v1 given a Y1 and S0
function v1 = nfc(Y1,S0)
n = 41;
Z0 = 50;
A = S0;
S = zeros(n,n);
for k = 1:n,
for l = 1:n,
S(k,l)=A(k,2*l-1)*cos(A(k,2*l)*pi/180)+i*A(k,2*l-1)*sin(A(k,2*l)*pi/180);
end
end
Zparam = Z0*inv(eye(n)-S)*(eye(n)+S); % Zparameters of n-port system
Yparam = inv(Zparam);
W = Yparam; % Ys matrix
m = 20; % Number of receivers
r = n-1; % Maximum n-1
W11 = W(1:m,1:m);
W12 = W(1:m,(m+1):r);
W13 = W(1:m,r+1);
W21 = W((m+1):r,1:m);
W22 = W((m+1):r,(m+1):r);
W23 = W((m+1):r,r+1);
W31 = W(r+1,1:m);
W32 = W(r+1,(m+1):r);
W33 = W(r+1,r+1);
Yc = inv(W22 - W21*inv(W11)*W12 + Y1); % Complex Y matrix
Y = real(Yc); % Matrix M in paper
YY = imag(Yc); % Matrix N in paper
P = W22-W21*inv(W11)*W12; %*****W11+Y1 changed to W11
P1 = W31*inv(W11)*W12-W32; %*****W11+Y1 changed to W11
M = real(P);
M = 0.5*(M+M');
v2 = P1*(Y+YY*i); % Voltages as input to Y1
v1 = -v2*W21*inv(W11)-W31*inv(W11); % Voltages not connected to Y1 %*****W11+Y1 changed to W11
yin = v1*W13+v2*W23+W33;
returnUsing this code, we could feed the function a variety of Y1 values to try and determine a pattern between the Y1 and the v1. This way, we were able to modify Y1 in whichever fashion we liked to see if there were visible patterns that could be seen within the v1 values. The code that calls this function then uses the value of v1 and Y1 to plot graphs and look at specific values.




