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
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 CenterFile Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by