Not enough input arguments
Mostrar comentarios más antiguos
Please refer to the following link http://in.mathworks.com/help/gads/examples/coding-and-minimizing-a-fitness-function-using-the-genetic-algorithm.html
I simply did copy and paste of the program given in the following link as below. But it is showed an error "Not enough input arguments'
function y = simple_fitness(x)
y = 100 * (x(1)^2 - x(2)) ^2 + (1 - x(1))^2
FitnessFunction = @simple_fitness
numberOfVariables = 2
[x,fval] = ga(FitnessFunction,numberOfVariables)
What is the mistake which I am doing ?
3 comentarios
Binay Chandra
el 23 de Feb. de 2017
You have to separate out the simple_fitness function and genetic algorithm script. Just create the function
---------------------------------------------------
function y = simple_fitness(x)
y = 100 * (x(1)^2 - x(2)) ^2 + (1 - x(1))^2;
end
---------------------------------------------------
and execute the genetic algorithm scripts at the command window.
---------------------------------------------------
FitnessFunction = @simple_fitness;
numberOfVariables = 2;
[x,fval] = ga(FitnessFunction,numberOfVariables)
---------------------------------------------------
Rakesh Jain
el 23 de Feb. de 2017
Walter Roberson
el 23 de Feb. de 2017
Yes, you need to put functions into files; you cannot use the "function" keyword at the command line.
Respuestas (0)
Categorías
Más información sobre Genetic Algorithm en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!