You are on page 1of 1

MATLAB Command Window Page 1

>> a=loadcase('case5')
% POWER SYASTEM ANALYSIS USING NR
% BEFORE CONTINGENCY
b = runopf(a)
bus_voltage_before=b.bus(:,8)
bus_angle_before=b.bus(:,9)
P_loss_before=sum(b.branch(:,14)+b.branch(:,16))
Q_loss_before=sum(b.branch(:,15)+b.branch(:,17))
random_branch_selection=randi([1 6])
a.branch(random_branch_selection,11)=0
% AFTER CONTINGENCY
b=runopf(a)
bus_voltage_after=b.bus(:,8)
bus_angle_after=b.bus(:,9)
P_loss_after=sum(b.branch(:,14)+b.branch(:,16))
Q_loss_after=sum(b.branch(:,15)+b.branch(:,17))
% CHANGE IN VOLTAGE,ANGLE,PLOSS&QLOSS
CHANGE_IN_VOLTAGE=bus_voltage_after-bus_voltage_before
CHANGE_IN_ANGLE=bus_angle_after-bus_angle_before
CHANGE_IN_PLOSS=P_loss_after-P_loss_before
CHANGE_IN_QLOSS=Q_loss_after-Q_loss_before
disp('USAMA REG#36')

You might also like