How can I pass data to a function for fminsearch that is not to be optimized?
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
Matt Kindig
2013-8-15
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Nonlinear Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!