If statement didnt work correctly

3 visualizaciones (últimos 30 días)
Mariam Gasra
Mariam Gasra el 26 de Mzo. de 2019
Comentada: Jan el 3 de Mayo de 2019
If i run the program if p less than min the result must be equal to zero but in this programme the result equal to min can any one correct the program
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
if P<min(P,DA.Ph)
P=0;
P=P+P;
else
P=P;
end
if P>max(P,DA.Pl)
P=0;
P=P+P;
else
P=P;
end
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);
table(DA.Unit,P,C,'V',{'Unit' 'Power' 'Cost'})
  19 comentarios
Mariam Gasra
Mariam Gasra el 28 de Mzo. de 2019
If I enter the above data i get3 value of P : 435.2, 299.97,130.66 If min of first p =500 Then first p should equal to zero by if statement conditions
For loop it's for number of unit
Jan
Jan el 3 de Mayo de 2019
@Mariam: You still did not mention, what the problem is. Posting a bunch of unclear question might decrease the interest of the forum in reading your questions.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by