clear
clc
%Defining Variables
unit=input('input the number of unit:');
D=input('input total load :'); dP=D;
n=input('insert number of iteration:');
for i=1:unit
a(i)=input('constant=');
b(i)=input('coff P');
c(i)=input('coff P^2');
B(i)=input('losses');
min(i)=input('main');
max(i)=input('max');
end
dB=diag(B);
x=max(b);
for i=1:n
while abs(dP)>0.00001
for i=1:unit
P(i)=(x-b(i))./(2*(c(i)+x*dB));
end
P=min(min(i)); P=max(max(i));
dP=D+P'*los(i)*P-sum(P);
x=x+dP*2/(sum(1./c(i)));
end
end
for i=1:unit
C(i)=a(i)+b(i).*P+c(i).*P.*P;
end
totalCost=sum(C);
display(totalCost);
lamda=x; display(lamda);
Loss=P'*B*P; display(Loss);
display(P);
display(C);
unit=3
D=850
n=1
constanat= 605 and 310 and 78
coff P= 7.92 and 7.85 and 7.97
coff P^2= 0.001562 and 0.00194 and 0.00482
B= 0.00003 and 0.00009 0.00012
min=100 and 100 and 50
max= 600 and 400 and 300
I would fix errors in this code

댓글 수: 1

Jan
Jan 2019년 5월 3일
If you mention, that you want to fix an error, be so kind and explain, what the error is. Do you get an error message, then post a complete copy of it. Or does the result differ from your expectations? Then explain both, the result and your expectations.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Performance and Memory에 대해 자세히 알아보기

제품

릴리스

R2015b

태그

아직 태그를 입력하지 않았습니다.

질문:

2019년 3월 31일

댓글:

Jan
2019년 5월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by