Formation of Z
Formation of Z
Program:
clear; clc; nbus=input('Enter the no of Buses:'); zdata=input('Enter the zdata in the form "From bus | To bus | Impedance value":\n'); [elements colums]=size(zdata); Zbus=[]; currentbusno=0; for c=1:elements From=zdata(c,1); To=zdata(c,2); zpri=zdata(c,3); newbus=max(From,To); ref=min(From,To); [rows cols]=size(Zbus); if newbus>currentbusno && ref==0 Zbus=[Zbus zeros(rows,1);zeros(1,cols) zpri]; currentbusno=newbus; continue end if newbus>currentbusno && ref~=0 Zbus=[Zbus Zbus(:,ref);Zbus(ref,:) zpri+Zbus(ref,ref)]; currentbusno=newbus; continue end if newbus<=currentbusno && ref==0 Zbus=Zbus-1/(Zbus(newbus,newbus)+ zpri)*Zbus(:,newbus)*Zbus(newbus,:); currentbusno=newbus; continue end if newbus<=currentbusno && ref~=0 Zbus=Zbus-1/(zpri+Zbus(From,From)+Zbus(To,To)2*Zbus(From,To))*((Zbus(:,From)-Zbus(:,To))*((Zbus(From,:)-Zbus(To,:)))); currentbusno=newbus; continue end end Zbus
Output:
Enter the no of Buses:3 Enter the zdata in the form "From bus | To bus | Impedance value": [1 0 0.25;1 2 0.1;2 0 0.25;2 3 0.1;3 1 0.1]
Zbus = 0.1397 0.1103 0.1250 0.1103 0.1397 0.1250 0.1250 0.1250 0.1750