Since ‘objective function’ implies curve fitting, try something like this —
y = 2.5*exp(-(x-5).^2/2)+randn(size(x))*0.25;
objfcn = @(b,x) b(1).*exp(-(x-b(2)).^2*b(3));
fitnessfcn = @(b) norm(y-objfcn(b,x));
[B,fval] = ga(fitnessfcn, Parms)
Optimization terminated: average change in the fitness value less than options.FunctionTolerance.
plot(x, objfcn(B,x), '-r')
The parameter estimates here (2.69, 4.97, 0.666) are reasonably accurate when compared to the actual parameters (2.5, 5.0, 0.5) in this relatively simple problem. The norm of the residuals is 2.71.
.