0% found this document useful (0 votes)
100 views6 pages

Zbus Program

The document describes a MATLAB program that builds a Zbus matrix by adding branch elements row by row from an input matrix called zprimary. The program initializes an empty Zbus matrix and iterates through each row of zprimary. It identifies the "from" and "to" buses and value for each branch and applies the appropriate logic to update the Zbus matrix, increasing its dimensions if necessary to include new buses. The output shows the final populated Zbus matrix.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views6 pages

Zbus Program

The document describes a MATLAB program that builds a Zbus matrix by adding branch elements row by row from an input matrix called zprimary. The program initializes an empty Zbus matrix and iterates through each row of zprimary. It identifies the "from" and "to" buses and value for each branch and applies the appropriate logic to update the Zbus matrix, increasing its dimensions if necessary to include new buses. The output shows the final populated Zbus matrix.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

Tutorial no 2:Aim:- Building Zbus matrix using matlab

Program
% program for building of Zbus by addition of branch or link
% Zprimary = [elementno from to value]
clear
zprimary =[
1 1 0 0.25
2 2 1 0.1
3 3 1 0.1
4 2 0 0.25
5 2 3 0.1]
[element columns] = size (zprimary)
% to begin with zbus matrix is null matrix
zbus=[]
% currentbusno indicates maximum no of buses added until now
currentbusno=0
%process each row of zprimary
for count=1:element,
[rows cols]=size(zbus)
from=zprimary(count,2)
to=zprimary(count,3)
value=zprimary(count,4)
% newbus variable indicatesthe maximum of the two buses
newbus=max(from,to)
%ref variable indicates the minimum of the two buses
ref=min(from,to)
% type 1
%A new element is added from new bus to ref bus
if newbus>currentbusno & ref ==0
zbus=[zbus zeros(rows,1)
zeros(1,cols) value]
currentbusno=newbus
continue
end
%type 2
%A new element is added from new bus to old bus other than ref
if newbus>currentbusno & ref ~=0
zbus=[zbus zbus(:,ref)
zbus(ref,:) value+zbus(ref,ref)]
currentbusno=newbus
continue
end
%type 3
%Anew element is added between an old bus and ref
1

if newbus<=currentbusno & ref==0


zbus=zbus-1/(zbus(newbus,newbus)+value)*zbus(:,newbus)*zbus(newbus,:)
continue
end
%type 4
% a new element is added between two old buses
if newbus<=currentbusno & ref ~=0
zbus=zbus-1/(value + zbus (from, from)+ zbus (to,to) - 2* zbus(from,to))* ((zbus(:,from)zbus(:,to))* ((zbus(from,:)- zbus(to,:))))
continue
end
end
Output:zprimary =
1.0000

1.0000

0.2500

2.0000

2.0000

1.0000

0.1000

3.0000

3.0000

1.0000

0.1000

4.0000

2.0000

5.0000

2.0000

3.0000

0.2500
0.1000

element =
5
columns =
4
zbus =
[]
currentbusno =
0
rows =
0

cols =
0
from =
1
to =
0
value =
0.2500
newbus =
1
ref =
0
zbus =
0.2500
currentbusno =
1
rows =
1
cols =
1
from =
2
to =
1
value =
0.1000

newbus =
2
ref =
1
zbus =
0.2500

0.2500

0.2500

0.3500

currentbusno =
2
rows =
2
cols =
2
from =
3
to =
1
value =
0.1000
newbus =
3
ref =
1
zbus =
0.2500

0.2500

0.2500

0.2500

0.3500

0.2500

0.2500

0.2500

0.3500
4

currentbusno =
3
rows =
3
cols =
3
from =
2
to =
0
value =
0.2500
newbus =
2
ref =
0
zbus =
0.1458

0.1042

0.1458

0.1042

0.1458

0.1042

0.1458

0.1042

0.2458

rows =
3
cols =
3
from =
2

to =
3
value =
0.1000
newbus =
3
ref =
2
zbus =
0.1397

0.1103

0.1250

0.1103

0.1397

0.1250

0.1250

0.1250

0.1750

You might also like