How can I use the Optimization Toolbox to optimize an objective function to a certain target value?

I can use the Optimization Toolbox functions (fminbnd, fmincon, fminsearch, fminunc, fseminf) to optimize an objective function to a minimum value. How can I instead optimize an objective function to a certain target value?

 Accepted Answer

There is no out-of-the-box support in the Optimization Toolbox for optimizing an objective function to a target value. Instead, please try to minimize the absolute difference between the objective function output and your target value. The code for this could look something like the following for the function "fminbnd":
% "target" is the value you want the objective function to target
% "objfun" is the objective function
target_fun = @(x) abs(objfun(x) - target)
optimized = fminbnd(target_fun, ...)
% optimized will be the optimized input value that produces the output value closest to "target"

More Answers (0)

Categories

Find more on Optimization in Help Center and File Exchange

Products

Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!