comparing element of matrix

4 views (last 30 days)
Mariam Gasra on 29 Mar 2019
Commented: Jan on 3 May 2019
clc;
unit=input('input the number of unit:');
Bdat1=input('transmission losses considered matrix:');
B=Bdat1;
dB=diag(B);
data1=input('input the data:n a b c min max');
DA=array2table(data1,'V',{'Unit' 'a' 'b' 'c' 'Pl' 'Ph'});
x=max(DA.b);
n=input('insert number of iteration:')
for i=1:n
while abs(dP)>0.00001
P=(x-DA.b)./(2*(DA.c+x*dB));
P=min(P,DA.Ph); P=max(P,DA.Pl);
dP=D+P'*B*P-sum(P);
x=x+dP*2/(sum(1./DA.c));
end
end
P((P> DA.Pl) | (P < DA.Ph)) = 0;
C=DA.a+DA.b.*P+DA.c.*P.*P;
totalCost=sum(C);
display(totalCost);
lamda=x; display(lamda);
Loss=P'*B*P; display(Loss);
display(P);
display(C);
%% Economic load dispatch of Real power
% dP is change during iterations
% B is loss coefficients matrix
% dB is loss vector
% DA is data of units a Table
% x is lambda,
% P is Real Power vector of all units
% C is cost of production individual units
% totalCost for all units
% Loss in transmission
% Pl Ph are min and max Constraints
input the number of unit:3
transmission losses considered matrix:[0.00003 0 0;0 0.00009 0;0 0 0.00012]
input the data:n a b c min max[1 605 7.92 0.001562 500 600;2 310 7.850 0.00194 100 400;3 78 7.97 0.00482 50 300]
insert number of iteration:1
if i run the programme i get all value of P =0
but i want if :P less than min or greater than max then only this element should be =zero and other P dosent change
Jan on 3 May 2019
This is not clear yet: "if :P less than min or greater than max then only this element should be =zero and other P dosent change"? What does it mean?

Categories

Find more on MATLAB Coder in Help Center and File Exchange

R2015b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!