フィルターのクリア

If statement didnt work correctly

5 ビュー (過去 30 日間)
Mariam Gasra
Mariam Gasra 2019 年 3 月 26 日
コメント済み: Jan 2019 年 5 月 3 日
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 件のコメント
Mariam Gasra
Mariam Gasra 2019 年 3 月 28 日
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 2019 年 5 月 3 日
@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.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by