How can I pass data to a function for fminsearch that is not to be optimized?

4 Ansichten (letzte 30 Tage)
I am using fminsearch to optimize a function, but some variables are not part of the objective function. Currently I pass the "data" as global variables, but I am wondering if there is a better way to do this.
For example, say I have a function that I want to optimize as follows:
f = fun(x0, data);
I want to find the values of x0 that minimize f, but I need to provide additional "data" which does not change.
  1 Kommentar
Matt Kindig
Matt Kindig am 15 Aug. 2013
There are a couple of ways to do this. In the Help docs for fminsearch() there is a link to "Parameterizing Functions" that explains how to do this. See also Example 2 in the fminsearch documentation.
doc fminsearch

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by