MATLAB中输入参数的数目不足该如何解决。

function y = simple_fitness(x)
y = 100*(x(1)^2 - x(2))^2 + (1 - x(1))^2;
function [c,ceq] = simple_constraint(x)
c = [1.5 + x(1)*x(2) + x(1) - x(2);-x(1)*x(2) + 10];
ceq = [];
Objective Function = @simple_fitness;
nvars = 2;
LB = [0 0];
UB = [1 13];
ConstraintFunction = @simple_constraint;
[x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,ConstraintFunction)
simple_fitness
输入参数的数目不足。
出错 simple_fitness (line 2)
y = 100*(x(1)^2 - x(2))^2 + (1 - x(1))^2;
我用的是MATLAB64位R2016a
我经常遇到输入参数数目不足的问题,有谁能告诉我这怎么解决?

 採用された回答

0 投票

试试这样:
ObjectiveFunction = @(x)100*(x(1)^2 - x(2))^2 + (1 - x(1))^2;
ConstraintFunction = @(x)deal([1.5 + x(1)*x(2) + x(1) - x(2);-x(1)*x(2) + 10],[]);
nvars = 2;
LB = [0 0];
UB = [1 13];
[x,fval] = ga(ObjectiveFunction,nvars,[],[],[],[],LB,UB,ConstraintFunction)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeOptimization Toolbox 快速入门 についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!