MATLAB: Use fsolve function in genetic algorithm toolbox

genetic algorithmMATLAB

I have a one-variable nonlinear equation that needs to be solved with the " fsolve" function. This equation also has a parameter that should be optimized by the genetic algorithm. To use the genetic algorithm toolbox, I have to write a separate objective function file for it which should contain the " fsolve" function. But how to define the parameter to be optimized in the first line? I can not define the input variable due to the " fsolve" function.

Best Answer

fun = @(x, param) 5 + exp(-(x-param).^2);
guess = 0.12345;
ga( @(param) fsolve( @(x) fun(x, param), guess), .... )