Indexing input must be numeric, logical or ':'.

3 次查看(过去 30 天)
function [x] = cost1(x)
mtgb=x(1);
pafcb=x(2);
utilityb=x(3);
%objective function =mt+pafc+pv+wt+bat+utility=PL(load demand)
run('E:\my project\wt.m')
for i=1:24
k=x(1)+x(2)+x(3)+a(i)+c(i);
bat=30;
if k+bat>=l(i)
display('load demand is met')
rem=k-l(i)+bat
else
display('load demand is not met')
k+bat>=l(i)
rem=l(i)-k-bat
end
end
%calculation of cost for the generation
%As of now we are neglecting the start up cost and shut down cost
% considering only bid cost for the different utilities
for i=1:24
m(i)=(x(1)*0.457+x(2)*0.294+x(3)*b(i)+a(i)*1.073+c(i)*2.584+bat*0.38)
end
end
i want to run it in gatool nd want to get the best values
  1 个评论
David Young
David Young 2014-9-9
Please format the code in your question. Put two spaces at the start of each line, or select it and use the "{} Code" button.

请先登录,再进行评论。

回答(1 个)

Salaheddin Hosseinzadeh
Hi Aditya,
I guess your problem is in the line below
m(i)=(x(1)*0.457+x(2)*0.294+x(3)*b(i)+a(i)*1.073+c(i)*2.584+bat*0.38)
It would be good if you could tell us, in which line the error exist, you normally should get this information from the prompted error.
I guess x(l) is the problem
Apparently you have a variable named l (is L not one(1)), which may have non integer values. You're using l (L) to refer to x indexes, so you should make sure L values are all integer and grater than 0, not even 0.
Check L values and let us know what happened.
If the problem was not solved let us know about the error line plz.
Good Luck!

类别

Help CenterFile Exchange 中查找有关 Word games 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by