You are on page 1of 4

clc;

clear all;
nbus=input('Enter the total no of bus excluding ref bus:');
zbus=zeros(nbus,nbus);
t=1;
while t==1;
s=menu('specify the case no','connect a new bus to ref bus','connect an oldbus to new
bus','connect 2 old buses','connect an old bus to ref bus','quit');
switch scase{1}zb=input('Enter the impedance value:');zbus=zb;case{2}n=input('Enter the new
bus no:');zb=input('Enter the reactance value:');for i=1:nif i==nzbus(n,n)=zbus(n-1,n1)+zb;elsezbus(i,n)=zbus(i,n-1);zbus(n,i)=zbus(n-1,i);endendcase{3}l=input('Enter the existing
bus no1:');n=input('Enter the existing bus no2:');zb=input('Enter the reactance
value:');n=n+1;fori=1:nif i==nzbus(n,n)=zbus(1,1)+zb+zbus(n-1,n-1)-(2*zbus(1,n1));zbus(n,n);elsezbus(i,n)=zbus(1,i)-zbus(i,n-1);zbus(i,n);zbus(n,i)=zbus(i,n);endfor i=1:nbusfor
j=1:nbusif i==jzbus(i,j)=zbus(i,j)(zbus(i,n)*zbus(n,j)/zbus(n,n));zbus(j,i)=zbus(i,j);zbus(i,j)=zbus(j,i);elsezbus(i,j)=zbus(i,j)(zbus(i,n)*zbus(n,j)/zbus(n,n));endendendfor
i=1:nzbus(i,n)=0;zbus(n,i)=0;endcase{4}n=input('Enter the bus no:');zb=input('Enter the
reactance value:');n=n+1;for i=1:nif i==nzbus(n,n)=zbus(n-1,n-1)+zb;else
zbus(i,n)=zbus(i,n-1);zbus(n,i)=zbus(n-1,i);endendfor i=1:nfor j=1:nif i==jzbus(i,j)=zbus(i,j)(zbus(i,n)*zbus(n,j)/zbus(n,n));zbus(j,i)=zbus(i,j);zbus(i,j)=zbus(j,i);elsezbus(i,j)=zbus(i,j)(zbus(i,n)*zbus(n,j)/zbus(n,n));endendendcase{5}'End the program'choice=menu('Would you
like to print program or end the program','Print','End');if choice==1zbusendt=0;endend

clear all; %CLEARS THE CONTENT OF MEMORY OR WORKSPACE


clc
%CLEARS THE SCREEN
% GETTING INPUT DATA FROM THE PROGRAMMER
disp('
THE INPUT DATAS ARE AS FOLLOWS
nb=input('the number of buses\n');
nl=input('the number of lines\n');
sb=input('the number of starting buses\n');
eb=input('the number of ending buses\n');
sli=input('enter the details of series line impedance\n');
lca=input('enter the detail of line impedance\n');
% EXECUTION STARTS HERE

');

for m=1:nb
for n=1:nb
if m==n||m~=n
if sli(m,n)==0
n=n+1;
else
y(m,n)=+sli(m,n)^-1+lca(m,n);
y(n,n)=+sli(m,n)^-1+lca(m,n);
y(m,n)=-sli(m,n)^-1;
y(n,m)=y(m,n);
end
end
end
end
% OUTPUT OF Y-BUS
disp('
THE RESULT OF Y BUS MATRIX IS
ybus=y
% OUTPUT OF Z-BUS
zbus=ybus^-1;
disp('
THE RESULT CHECK MATRIX IS
chkmat=zbus*ybus
disp('
THE RESULT OF Z BUS MATRIX IS
zbus=zbus

');

');
');

Program:
clc;
clear all;
n=input('No of buses');
l=input('No of lines');
s=input('Impedance or Admittance');
for(i=1:l)
a=input('Starting bus');
b=input('Ending bus');
t=input('Admittance or Impedance value');
if(s==1)
y(a,b)=1/t;
else
y(a,b)=t;
end
y(b,a)=y(a,b);
end
ybus=zeros(n,n);
for(i=1:n)
for(j=1:n)
if(i==j)
for(k=1:n)
ybus(i,j)=ybus(i,j)+y(i,k);
end
else
ybus(i,j)=-y(i,j);

end
ybus(j,i)=ybus(i,j);
end
end
ybus

You might also like