| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1042 人关注过本帖
标题:我是新手,请帮忙!
只看楼主 加入收藏
yxx318
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2007-1-18
收藏
 问题点数:0 回复次数:1 
我是新手,请帮忙!

哪位大哥/大姐知道怎样在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
hitzhang
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:21
帖 子:369
专家分:52
注 册:2006-9-24
收藏
得分:0 
switch是matlab的关键字不能当作普通变量使用

2007-01-18 18:31
快速回复:我是新手,请帮忙!
数据加载中...
 
   



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

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