Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
回复
 
主题工具 显示模式
旧 2010-09-23, 10:16   #1
footballandsun
初级会员
 
注册日期: 2008-11-13
年龄: 46
帖子: 3
声望力: 0
footballandsun 正向着好的方向发展
微笑 运用遗传算法出现这样的问题,怎办

本人在运用matlab R2010b自带的遗传算法工具箱搜索3个参数,定义的适应函数为source.m。
运行时总是提示:
??? Index exceeds matrix dimensions.

Error in ==> initializega at 66
rng = (bounds(:,2)-bounds(:,1))'; %The variable ranges'

Error in ==> ga at 148
startPop=initializega(80,bounds,evalFN,evalOps,opts(1:2));

Error in ==> tmp at 113
zwj= ga(@source,3,[],[],[],[],lb,ub);

%------以下是原代码---------------
lb=[0 1 10]; % 三个参数的下界
ub=[10 15 1000]; % 三个参数的上界
options = gaoptimset('InitialPopulation',[.2 2 200]);% 给初始值
zwj= ga(@source,3,[],[],[],[],lb,ub);

% -------------定义的适应函数为source.m
function sum=source(x)
[f u]=textread('SourceAmp.dat','%f %f');
sum=0;
Vsp=8.4;
p=load('p.txt');
s=load('s.txt');
Tsp=s-p;
r=Tsp.*Vsp;
for i=1:length(f)
obs=u(i);
teo=x(:,1)./(1+(f(i)./x(:,2)).^2).*exp(-pi.*r.*f(i)./3.5./x(:,3));
sum=sum+(teo-obs).^2./sqrt(teo.*obs);
end
footballandsun 当前离线   回复时引用此帖
回复

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码



所有时间均为北京时间。现在的时间是 17:29


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