# error to get a result

6 views (last 30 days)
Mariam Gasra on 31 Mar 2019
Commented: Jan on 3 May 2019
clear
clc
%Defining Variables
unit=input('input the number of unit:');
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
Jan on 3 May 2019
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.

### Categories

Find more on Language Fundamentals in Help Center and File Exchange

### Tags

No tags entered yet.

R2015b

### Community Treasure Hunt

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

Start Hunting!