MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   执行遗传算法(内附程式码)却出现error (https://www.labfans.com/bbs/showthread.php?t=11021)

ptt123 2010-03-16 01:06

执行遗传算法(内附程式码)却出现error
 
各位大大好

小弟执行遗传算法程式码(百度连结 [url]http://zhidao.baidu.com/question/101329132.html[/url], 最佳答案那个)却出现error


(1)(把2.1~2.7存在同一个M-FILE里面,用genmain05.m 执行)
[COLOR="red"])Error in ==> genmain05 at 9
pop=initpop(popsize,chromlength);[/COLOR][/COLOR]

(2)(把2.1~2.8个别储存成为一个M-FILE里面,共8个,用genmain05.m 执行

[COLOR="red"]??? Undefined command/function 'calfitvalue'.

Error in ==> genmain05 at 14
fitvalue=calfitvalue(objvalue);[/COLOR]

还请各位前辈不另赐教

beginer 2010-03-16 09:50

回复: 执行遗传算法(内附程式码)却出现error
 
不能都放在一个m文件里,你分别把2.1~2.8放在不同的m文件里,其中2.1~2.7的文件名要和函数名相同,2.8是主程序m文件,这样才能正确调用。


所有时间均为北京时间。现在的时间是 14:06

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.