Hello Hynod,
I understand that you want to pass handle as an input for fmincon function. To achieve this, we can use the integral function which is a numerical integrator function.
For a sample demonstration of this process, kindly refer to the following steps:
% Initial point
x0 = [1 2];
% Call fmincon to minimize the objective function.
[x, fval] = fmincon(@myObjective, x0);
disp(x);
disp(fval);
function f = f(x)
% This function defines the function f(x) to be integrated.
f = x.^2 - 2*x + 1;
end
function objective = myObjective(x)
% This function returns the objective function value, which is the integral of f(x).
objective = integral(@f, x(1), x(2));
end
Kindly refer to the following MATLAB documentation for further understanding on fmincon and integral
- https://www.mathworks.com/help/optim/ug/fmincon.html
- https://www.mathworks.com/help/matlab/ref/integral.html
Hope this helps in resolving the issue you were facing.
Regards,
Gowtham