MATLAB: Optimization of one output of a vectorfunction using fminunc

optimization toolbox fminuncvectorfunction

Hi!
Last time I got a very helpful idea. Now I defined a vectorfunction which has several variables x1,x2,x3,u1,u2 and also several outputs y1,y2,y3,…,yN. Now I would like to optimize only one output, i.e. I optimize f.ex. only y3. In my case y3 is a function that I get from y1,y2… .
I tried to find the answer, but mostly fminunc were used to optimize y or y1,y2,y3,….. What is the command in the fminunc solver to optimize only one output?
Thanks

Best Answer

Inside of your objective function, only return that output:
function y3 = myobjfun(x)
% do whatever
y3 = something;
end