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

4 vues (au cours des 30 derniers jours)
Sonoma Rich
Sonoma Rich le 15 Août 2013
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 commentaire
Matt Kindig
Matt Kindig le 15 Août 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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Get Started with Optimization Toolbox dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by