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

4 visualizzazioni (ultimi 30 giorni)
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 Commento
Matt Kindig
Matt Kindig il 15 Ago 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

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by