d=[1 550 8.1000 0.00028 0 680
2 309 8.1000 0.00056 0 360
3 307 8.1000 0.00056 0 360
4 240 7.7400 0.00324 60 180
5 240 7.7400 0.00324 60 180
6 240 7.7400 0.00324 60 180
7 240 7.7400 0.00324 60 180
8 240 7.7400 0.00324 60 180
9 240 7.7400 0.00324 60 180
10 126 8.6000 0.00284 40 120
11 126 8.6000 0.00284 40 120
12 126 8.6000 0.00284 55 120
13 126 8.6000 0.00284 55 120];
Pd=1800;
alpha=d(:,2);
n=d(:,1);
beta=d(:,3);
gamma=d(:,4);
Pmin=d(:,5);
Pmax=d(:,6);
DelP=Pd; i=1;
Iteration=i;
Lamda=8.35;
while abs(DelP)> 0.00001
P=(Lamda-beta)./(gamma.*2);
P=min(P,Pmax);
P=max(P,Pmin);
DelP=Pd-sum(P); Lamda=Lamda+DelP/(sum(1./(2*gamma)));
costI(:,i)=alpha+(beta.*P)+(gamma.*P.*P);
totalCost_iteration(i,1)=sum(costI(:,i));
Iteration(i,1)=i;
i=i+1;
end
Cost=alpha+(beta.*P)+(gamma.*P.*P);
totalCost=sum(Cost);
totalPower=sum(P); table(d(:,1),P,Cost,'V',{'Unit' 'Power' 'Cost'})
display(totalCost);
display(totalPower);
figure
plot(Iteration,totalCost_iteration)
title('Convergest Graph')
xlabel('Number of Iteration')
ylabel('Cost(RM/h)')
Best Answer