There are couple reasons that you could be getting this error.
- This error occurs when the objective function produces a NaN output. To fix this, edit the function so that it does not produces NaN values, or set constraints on the function's inputs to prevent the objective function from producing NaN outputs.
- If you have nonlinear constraints, make sure that you are following this note in the documentation page for "ga":
"Note: Passing Extra Parameters (Optimization Toolbox) explains how to pass extra parameters to the objective function and nonlinear constraint functions, if necessary."