MATLAB: Fminunc stopped because it exceeded the function evaluation limit, options.MaxFunEvals = 100 (the default value).

optimization fminunc

what should i do if i get this kind of error?

Best Answer

  • Define the objective function by setting its output with the opposite sign as follows:
    function F=fun(x)
    The initial function that you presented does not have a finite global minimum, it tends to -inf due to the negative sign at the coefficient of x^6. The above function has a global minimum, so if you execute the code:
    x0 = 1;
    [x, fval] = fminunc (@fun,x0)
    then the algorithm finds the local minimum of -fun, therefore the global maximum of fun.