标题:我是新手,请帮忙!
取消只看楼主
yxx318
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-1-18
 问题点数:0 回复次数:0 
我是新手,请帮忙!

哪位大哥/大姐知道怎样在matlab中调用设非尔德大学推出的工具箱的M文件和函数?
可否告之小妹?
再有function ObjVal = objfun1(Chrom,switch);

% Dimension of objective function
Dim = 20;

% Compute population parameters
[Nind,Nvar] = size(Chrom);

% Check size of Chrom and do the appropriate thing
% if Chrom is [], then define size of boundary-matrix and values
if Nind == 0
% return text of title for graphic output
if switch == 2
ObjVal = ['DE JONG function 1-' int2str(Dim)];
% return value of global minimum
elseif switch == 3
ObjVal = 0;
% define size of boundary-matrix and values
else
% lower and upper bound, identical for all n variables
ObjVal = 100*[-5.12; 5.12];
ObjVal = ObjVal(1:2,ones(Dim,1));
end
% if Dim variables, compute values of function
elseif Nvar == Dim
% function 1, sum of xi^2 for i = 1:Dim (Dim=30)
% n = Dim, -5.12 <= xi <= 5.12
% global minimum at (xi)=(0) ; fmin=0
ObjVal = sum((Chrom .* Chrom)')';
% ObjVal = diag(Chrom * Chrom'); % both lines produce the same
% otherwise error, wrong format of Chrom
else
error('size of matrix Chrom is not correct for function evaluation');
end


% End of function


这段程序运行后,为什么总是提示:
??? Error: File: OBJFUN1.M Line: 33 Column: 33
Illegal use of reserved keyword "switch".



这是为什么?这段程序是GA中的.

搜索更多相关主题的帖子: Chrom switch function size 
2007-01-18 12:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-116710-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.342367 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved