![]() |
运用遗传算法出现这样的问题,怎办
本人在运用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 |
所有时间均为北京时间。现在的时间是 03:11。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.