error to get a result

1 次查看(过去 30 天)
Mariam Gasra
Mariam Gasra 2019-3-31
评论: Jan 2019-5-3
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 个)

类别

Help CenterFile Exchange 中查找有关 Language Fundamentals 的更多信息

标签

尚未输入任何标签。

产品


版本

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by