哪位大哥/大姐知道怎样在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中的.