2

Say I have a function

[f,g,h] = function (x)

In the file function.m in Matlab. How can I find the value x, e.g. using fminunc, which maximizes g? The fminunc documentation only handles the case when the objective function returns a single value.

4
  • What exactly do you want to find, the minimum of function? Commented May 12, 2013 at 9:57
  • I'm looking for x* = min_x h(x). Commented May 12, 2013 at 9:59
  • What is h, could you show what exactly function does? Commented May 12, 2013 at 10:03
  • If you don't use variables f and h. You can create a mimic function which call your function inside which passes the argument x to it and returns g only. Commented May 12, 2013 at 10:22

1 Answer 1

8

You must provide fminunc with a function that returns a scalar, so in your case you'll just have to declare a helper function that returns g:

g = function helper_func(x)
    [f, g, h] = func(x);

and feed the helper function into fminunc:

x = fminunc(@helper_func, x0);
Sign up to request clarification or add additional context in comments.

1 Comment

Are there any guidelines on how to combine multiple goals into a single scalar? How to weight conflicting goals, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.