Code Print Till YBUS
Code Print Till YBUS
m 1 of 1
function main_121EE0702()
nb= input('no of buses: \n');%number of buses
Ybus_matrix = YBUS(nb);% gets Ybus matrix from the YBUS program
disp(Ybus_matrix);% display YBus
end
4/3/25 10:39 AM C:\Users\lenovo\AppData\Loca...\BUSDATA.m 1 of 1
case 4
bus=[1 1 0.5 0.3099 0 0 1 0 0 0;
2 3 1.7 1.0535 0 0 1 0 0 0;
3 3 2.0 1.2394 0 0 1 0 0 0;
4 2 0.8 0.4958 318 0 1 0 -5 5;];
case 1
bus=[1 1 0 0 0 0 1.05 0;
2 3 0 0 2 1 1.0 0;];
end
end
4/3/25 10:39 AM C:\Users\lenovo\AppData\Loc...\LINEDATA.m 1 of 1
function Y = YBUS(nb)
line_data = LINEDATA(nb);
for i=1:n_lines
Y(FB(i,1),TB(i,1))=-y(i)/a(i);% fills non diagonal elements
Y(TB(i,1),FB(i,1))=-y(i)/a(i);% fills non diagonal elements
end
for i = 1:n_buses% filling diagonal elements in the matrix (series+shunt)
for j = 1:n_lines
if FB(j,1) == i
Y(i,i) = Y(i,i) + y(j,1)/(a(j,1)*a(j,1)) + B(j,1);
elseif TB(j,1) == i
Y(i,i) = Y(i,i) + y(j,1) + B(j,1);
end
end
end
end