Borrar filtros
Borrar filtros

How do I minimise function with many outputs?

18 visualizaciones (últimos 30 días)
Vykta Wakandigara
Vykta Wakandigara el 2 de Nov. de 2018
Comentada: Walter Roberson el 2 de Nov. de 2018
I have an anonymous function which produces multiple outputs. How do I use fmincon to minimise with respect to the first output?

Respuesta aceptada

Walter Roberson
Walter Roberson el 2 de Nov. de 2018
Where you currently have
fmincon(HandleToAnonymousFunction, ......)
use
fmincon(@(X) HandleToAnonymousFunction(X), .....)
This will have the effect of discarding all except the first output.
I am assuming here that when you say that it produces multiple outputs, that you mean that the current function does something like deal() to emit multiple output variables, or else is a simple handle to a function that has multiple potential outputs such as min: @min would be an example of an anonymous function that can return multiple outputs.
If what you mean is instead that your function returns a vector or array of values instead of a scalar, then the approach would be
First = @(V) V(1);
fmincon(@(X) First(HandleToAnonymousFunction(X)), .....)

Más respuestas (1)

Caglar
Caglar el 2 de Nov. de 2018
Editada: Walter Roberson el 2 de Nov. de 2018
  1 comentario
Walter Roberson
Walter Roberson el 2 de Nov. de 2018
That material is still correct, but deals primarily with the case that the output to be returned is not the first output. The first output can be handled differently.

Iniciar sesión para comentar.

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by