Code: Select all

```
function[Y] = busadmittance(z)
ne = z(:,1); nt = z(:,2); r = z(:,3); x = z(:,4); lines = length(ne);
buses = max(max(ne), max(nt));
Z = r + 1j*x;
y = ones(length(Z),1)./Z;
Y = zeros(buses,buses);
```

Code: Select all

```
for k = 1:buses
for l = 1:lines
if ne(l) == k || nt(l) == k
Y(k,k) = Y(k,k)+ y(l);
end
end
end
for k = 1:lines
if ne(k)>0 && nt(k) > 0
Y(ne(k),nt(k)) = -y(k);
Y(nt(k),ne(k)) = -y(k);
end
end
```