0% found this document useful (0 votes)
36 views

'Enter Data of Branch:': While For End If

The document defines variables to store branch data and the bus impedance matrix. It then uses a while loop to repeatedly accept branch data inputs, check for different connection cases, and update the bus impedance matrix accordingly. The four cases involve: 1) a new branch connection, 2) a connection to an existing bus, 3) a connection between an existing generator and bus, and 4) a connection between two existing buses. After processing, it displays the final bus impedance matrix.

Uploaded by

Umair Abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

'Enter Data of Branch:': While For End If

The document defines variables to store branch data and the bus impedance matrix. It then uses a while loop to repeatedly accept branch data inputs, check for different connection cases, and update the bus impedance matrix accordingly. The four cases involve: 1) a new branch connection, 2) a connection to an existing bus, 3) a connection between an existing generator and bus, and 4) a connection between two existing buses. After processing, it displays the final bus impedance matrix.

Uploaded by

Umair Abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Dat=[];

Zbus=[];
con=0;
gen=0;
j=1;
while j>=1
Data=input('enter data of branch:');
for l=1:4
Dat(j,l)=Data(1,l);
end
if j==1&&Data(1,1)==1||Data(1,2)==1
disp('Case1')
Zbus(1,1)=Dat(1,3)+i*Dat(1,4);
else disp('You put The wrong bus no for
start:')
j=j-1;
end
if j~=1
b=size(Dat);
for n=1:j-1
for o=1:2
if (Data(1,1)==Dat(n,o))
con=con+1;
end
if Data(1,2)==Dat(n,o)
gen=gen+1;
end
end
end
end
if con>=1&&gen==0
disp('case2')
Zbus(:,j)=Zbus(:,Data(1,1));
Zbus(j,:)=Zbus(Data(1,1),:);
Zbus(j,j)=Data(1,3)+i*Data(1,4)+Zbus(Data(1,1),Data
(1,1));
con=0;
gen=0;
end
if
(con>=1||gen>=1)&&(Data(1,1)==0||Data(1,2)==0)
disp('case3')
Zbus(:,j)=Zbus(:,Data(1,1));

Zbus(j,:)=Zbus(Data(1,1),:);
Zbus(j,j)=Data(1,3)+i*Data(1,4)+Zbus(Data(1,1),Data
(1,1));
for h=1:j-1
for g=1:j-1
Zbus(h,g)=Zbus(h,g)((Zbus(h,j)*Zbus(j,g))/Zbus(j,j));
end
end
Zbus(:,j)=[];
Zbus(j,:)=[];
j=j-1;
con=0;
gen=0;
end
if (con>=1&&gen>=1)&&(Data(1,1)>0&&Data(1,2)>0)
disp('case4')
f=Data(1,1);
s=Data(1,2);
Zbus(:,j)=Zbus(:,f)-Zbus(:,s);
Zbus(j,:)=Zbus(f,:)-Zbus(s,:);
Zbus(j,j)=Zbus(f,f)+Zbus(s,s)2*Zbus(f,s)+Data(1,3)+i*Data(1,4);
for hu=1:j-1
for gu=1:j-1
Zbus(hu,gu)=Zbus(hu,gu)((Zbus(hu,j)*Zbus(j,gu))/Zbus(j,j));
end
end
Zbus(:,j)=[];
Zbus(j,:)=[];
j=j-1;
con=0;
gen=0;
end
Zbus
j=j+1;
end

You might also like