comparing element of matrix

1 次查看(过去 30 天)
Mariam Gasra
Mariam Gasra 2019-3-29
评论: Jan 2019-5-3
clc;
unit=input('input the number of unit:');
D=input('input total load :'); dP=D;
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
% D is total Load
% 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
input total load :850
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
  1 个评论
Jan
Jan 2019-5-3
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?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品


版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by