Not enough input arguments
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Utkarsh Konge
am 26 Nov. 2016
Beantwortet: Walter Roberson
am 26 Nov. 2016
I am trying to solve a simple optimization problem using GA.
Main file -
nvars = 3;
lb = [0; 0; 0];
ub = [1; 1; 1];
intcon = [1 2 3];
sol = ga(fun, nvars, [], [], [], [], lb, ub, [], intcon);
Function -
function val = fun(x)
%if (x(1)==1 || x(2)==1 || x(3)==1)
%val = 10000;
%else
a = x(1);
b = x(2);
c = x(3);
val = 10*a + 20*b - 30*c;
end
But it throws this error -
Error using fun (line 5)
Not enough input arguments.
Error in test_ga (line 7)
sol = ga(fun, nvars, [], [], [], [], lb, ub, [], intcon);
Need urgent help!!
Thank you.
Akzeptierte Antwort
Walter Roberson
am 26 Nov. 2016
sol = ga(@fun, nvars, [], [], [], [], lb, ub, [], intcon);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Genetic Algorithm finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!