Effacer les filtres
Effacer les filtres

comparing element of matrix

1 vue (au cours des 30 derniers jours)
Mariam Gasra
Mariam Gasra le 29 Mar 2019
Commenté : Jan le 3 Mai 2019
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 commentaire
Jan
Jan le 3 Mai 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?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB Coder dans Help Center et File Exchange

Produits


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by