中易网

too many input arguments. matlab

答案:2  悬赏:30  
解决时间 2021-02-03 06:22
function [X,FVAL,REASON,OUTPUT,POPULATION,SCORES] = zuiyou
%% This is an auto generated M file to do optimization with the Genetic Algorithm and
% Direct Search Toolbox. Use GAOPTIMSET for default GA options structure.
int c(8,8)={{0,12,14,10,20,25,27,18 },{12,0,5,13,6,14,41,39},{14,5,0,16,18,20,30,32},{10,13,16,0,14,27,15,12},{20,6,18,14,0,22,18,26},{25,14,20,27,22,0,27,32},{27,41,30,15,18,27,0,15},{18,39,32,12,26,32,15,0}}
int X(8,8);
int popsize;
int chromlength;
% #include
% #include
%
% {
% int i,j;
% srand((int)time(0));
%
% for(i=0;i<10;i++)
% {
% j=rand()%2;
% printf(" %d ",j);
% }
sum=0;
for i=1:8;
for j=i+1:8;
% srand((int)time(0));
% X[i][j]=rand();
% X[i][j]=rand()%2;
A=eye(40,28); % 生成一个 数值数组
A_str1=int2str(A) % 转换成 串数组。请读者自己用 size 检验。
%X[i][j]=ceil(fix(rand(0,1)*40));
if R(x)<0.9||AvgDelay>10
sum=c(i,j)*X(i,j)+(41*(R(x)-0.9)).^2;
else sum=c(i,j)*X(i,j);
%printf("%d",sum);
end
end
end

%initPop=initializega(40,[0,1],'fitness');%
%%Fitness function
fitnessFunction = @zuiyou;
%%Number of Variables
nvars = 8 ;
%Linear inequality constraints
Aineq = [0 12 14 10 20 25 27 18 ; 12 0 5 13 6 14 41 39 ; 14 5 0 16 18 20 30 32 ; 10 13 16 0 14 27 15 12 ; 20 6 18 14 0 22 18 26 ; 25 14 20 27 22 0 27 32 ; 27 41 30 15 18 27 0 15 ; 18 39 32 12 26 32 15 0 ];
Bineq = [3000 ; 3000 ; 3000 ; 3000 ; 3000 ; 3000 ; 3000 ; 3000 ];
%Linear equality constraints
Aeq = [];
Beq = [];
%Bounds
LB = 0 ;
UB = 1 ;
%Nonlinear constraints
nonlconFunction = [];
%Start with default options
options = gaoptimset;
%%Modify some parameters
pop=round(rand(40,28));
options = gaoptimset(options,'PopulationType' ,'bitString');
options = gaoptimset(options,'PopulationSize' ,40);
options = gaoptimset(options,'chromlength',28 );
options = gaoptimset(options,'MutationFcn' ,{ @mutationgaussian 1 1 });
options = gaoptimset(options,'Display' ,'off');
options = gaoptimset(options,'PlotFcns' ,{ @gaplotbestf @gaplotdistance @gaplotselection });
%%Run GA
[X,FVAL,REASON,OUTPUT,POPULATION,SCORES] = ga(fitnessFunction,nvars,Aineq,Bineq,Aeq,Beq,LB,UB,nonlconFunction,options);

运行提示:too many input arguments
该怎么解决啊?
最佳答案
你调用某个函数的时候,给的变量比较多,举个例子

function a=fun(b)

这个函数只能接受一个变量b,如果你这样用fun(1,2)肯定就会报错了。
全部回答
这是提示你输入参数过多。 你这函数输入参数只能是两个,不能多也不能少
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
show sb sth
现在在深圳石岩人民医院生孩子需要自己带待产
锌合金的东西会不会生锈
东缉虎营我想知道这个在什么地方
喝桑椹醋有什么作用?
浆溪地址有知道的么?有点事想过去
男朋友说老想勾搭我什么意思
WOWItemMaker怎么用啊~~~~~~~~~~~~
身高160体重45KG,是C罩杯的胸好还是D罩杯的
淘宝大学耿车人才培训中心怎么去啊,有知道地
在网上怎样可以查询个人基本信息?
如图所示,在空中有一水平方向的匀强磁场区域
“我们需要每个人都清楚学习英语是一点也不难
手机兼职真安全吗?
天水亭地址在哪,我要去那里办事
推荐资讯
学车时,学员都要挨骂吗?
我的建行卡(储蓄卡)能透支吗?目前没储蓄了
小说男女主都是黑道的现代言情小说
光绪元宝户部当制钱二十文值多少钱
嘉兴到义乌,坐最便宜的车去哪坐?大概多少钱
电脑连不上网,设置也打不开,是什么问题?
清晨中的送别300字作文
女儿大学毕业不工作,宅在家里
EXCEL打印预览是横版的,但打印出来的却是竖
怎样向老乡宣传转移就业思想工作
医药专业函授学历承不承认?
南充滴滴快车合法么
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?