필터 지우기
필터 지우기

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 CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by