查看单个帖子
旧 2009-03-28, 14:55   #1
jiandan
初级会员
 
注册日期: 2009-03-23
年龄: 39
帖子: 6
声望力: 0
jiandan 正向着好的方向发展
默认 [求助]遗传算法运行

我在做毕业设计,关于遗传算法运行的,我先在M文件中见了个目标函数:
function f = shufcn(y)
for j =1:size(y,1)
f(j) =0.0;
x = y(j,;
temp1 = 0;
temp2 = 0;
x1 = x(1);
x2 = x(2);
for i =1:5
temp1 = temp1+i.*cos((i+1).*x1+i);
temp2 = temp2+i.*cos((i+1).*x2+i);
end
f(j) =temp1.*temp2;
end
然后在命令窗口输入:
plotobjective (@shufcn,[-2 2;-2 2]);
>> FitnessFunction = @shufcn;
>> numberOfVariables =2;
>> [x,Fval,exitFlag,Output]=ga(FitnessFunction,numberOfVariables);
怎么运行不了的,出现错误提示:
??? Error using ==> ga
Too many input arguments.
请各位大侠帮帮忙啊,我以前运行过都可以的,但是不知道怎么今天就不行了,我还编了另外的函数,但是也是出现这种情况。
jiandan 当前离线   回复时引用此帖