Using 'fmincon' on a multivariate function

Solved! I found the answer in another question, link:
https://www.mathworks.com/matlabcentral/answers/279921-dealing-with-symbolic-vectors-and-function-files
Original Question: Hi All,
I have been trying for a couple of days to figure this out and am stuck! Any help would be greatly appreciated. I am trying to optimize an objective function that is a function of two variables. The objective function is derived using a series of Matrix/Vector operations where the final function takes two variables 'r1' and 'r2' and returns a scalar. My issue is that I derive the optimization function in symbolics and have attempted several methods to convert the symbolic expression into a usable function. In the example posted below I am using "matlabFunction" which returns a function of two variables 'r1' and 'r2'. What I need instead is a function of "r" which is vector valued where "r = [r(1);r(2)]";. If I go through and manual change "r1 ->r(1)" and "r2->r(2)" in "Wi_Stacked" before defining "Jfunctest" I get the correct answer from the optimizer. However if I use Jfunc the optimizer returns the following error:
"Caught-error breakpoint was hit in symengine>@(r1,r2)... Not enough input arguments."
Please Help!

Risposte (0)

Richiesto:

Ben
il 13 Apr 2017

Modificato:

Ben
il 13 Apr 2017

Community Treasure Hunt

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

Start Hunting!

Translated by