0% found this document useful (0 votes)
54 views2 pages

%formation of Y Bus: For If

This MATLAB code forms the Y bus matrix for a power system with 4 buses and 4 transmission lines. It first imports the line data with from and to bus numbers, resistance and reactance values. It then calculates the admittance values and forms the off-diagonal elements of the Y bus matrix based on the line connections. Finally, it calculates the diagonal elements by summing the admittances of all lines connected to each bus and outputs the full Y bus matrix.

Uploaded by

ViknshSarat
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)
54 views2 pages

%formation of Y Bus: For If

This MATLAB code forms the Y bus matrix for a power system with 4 buses and 4 transmission lines. It first imports the line data with from and to bus numbers, resistance and reactance values. It then calculates the admittance values and forms the off-diagonal elements of the Y bus matrix based on the line connections. Finally, it calculates the diagonal elements by summing the admittances of all lines connected to each bus and outputs the full Y bus matrix.

Uploaded by

ViknshSarat
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

%formation of Y bus

clc;
clear all;
%Getting line datas
% from to r x
zdata =[ 1 2 .025 .1
2 3 .02 .08
3 4 .05 .2
1 4 .04 .16];
n1=zdata(: ,1);
nr=zdata(: ,2);
r=zdata(: ,3);
x=zdata(: ,4);
nbr=length(zdata (: ,1));
nbus=max(max(n1),max(nr));
z=r+j*x;
y=ones(nbr,1)./z;
ybus=zeros(nbus,nbus); % initialize ybus to zero
for k=1:nbr; % formation of the off diagonal element
if n1(k)>0&nr(k)>0
ybus(n1(k),nr(k))=ybus(n1(k),nr(k))-y(k);
ybus(nr(k),n1(k))=ybus(n1(k),nr(k));
end
end
for n=1:nbus
for k=1:nbr
if n1(k)==n |nr(k) ==n
ybus (n,n) =ybus (n,n) +y(k);
else, end
end
end
ybus













output
ybus =
3.8235 -15.2941i -2.3529 + 9.4118i 0 -1.4706 + 5.8824i
-2.3529 + 9.4118i 5.2941 -21.1765i -2.9412 +11.7647i 0
0 -2.9412 +11.7647i 4.1176 -16.4706i -1.1765 +4.7059i
-1.4706 + 5.8824i 0 -1.1765 + 4.7059i 2.6471 -10.5882i

You might also like