MATLAB: Optimization running. Error running optimization. Too many input arguments.

errorgenetic algorithminputoptimizationpopulation

I am working on genetic algorithm toolbox but i have a problem with creation function. i want to initialize real valued population by using creation function. my function is ;
function Chrom = crtrp(Nind,FieldDR) Chrom = rand(Nind,Nvar) .* FieldDR; end
in an another m. file, i identified FieldDR for boundaries. Is this a true approach? when i run the program the error occurs as
Error running optimization. Too many input arguments.
i could not understand why this occurs. Thanks.
PS: I am using MATLAB 2010a and Optimization Toolbox 5.0

Best Answer

According to the documentation http://www.mathworks.com/help/toolbox/gads/f6174dfi10.html#f14223 the syntax for a creation function is
function Population = myfun(GenomeLength, FitnessFcn, options)
The input arguments to the function are
Genomelength — Number of independent variables for the fitness function
FitnessFcn — Fitness function
options — Options structure
The function returns Population, the initial population for the genetic algorithm.
Does your creation function satisfy this syntax? I really can't tell, but I am sure you can tell. Also, as you probably know, you must tell GA to use your creation function by setting the CreationFunction option to your creation function.
Alan Weiss
MATLAB mathematical toolbox documentation