Is there an elegant way to call fminsearch
to optimise the n'th output of a function? or would one need to define a new function that returns the n'th output of the original function and apply fminsearch
to this new function?
EDITED FOR CLARIFICATION:
i.e. given:
function [out1, out2] = myfunc(x)
% appropriate code
end
what is the simplest way to find the value of x that minimises out2?