How do I evaluate variables from my function at the optimum value and get them in the workspace?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
I call fmincon as follows: [theta_LL, Fval]=fmincon('LLobjnew', thetainit, [], [], [], [], lb, ub, @Nonlcon, optionsLL, data);
My function LLobjnew looks like this: function [LL, pr2] = LLobjnew(theta, data)
theta_LL has my optimum values. I output pr2 as above but it does not show up in the workspace. What I want to do is evaluate pr2 at the optimum values. Any way I can do this in the call to fmincon? Any way to do this at all? Pr2 is a matrix which is quite complicated, it depends on many of the parameters in theta in not so simple ways so I'm hoping to do this directly but anything that works.
Answers (1)
Alan Weiss
on 6 Dec 2013
function [LL, pr2] = LLobjnew(theta, data)
means pr2 is the gradient of LL with respect to the theta variables.
In any case, as long as you have GradObj set to 'off' you won't have problems with fmincon treating this incorrectly. (I am assuming that pr2 is not really the gradient of LL.)
As to your question, after you have fmincon calculate theta_LL, can you run
[LL, pr2] = LLobjnew(theta_LL, data)
and get pr2 that way?
Alan Weiss
MATLAB mathematical toolbox documentation
1 Comment
Ryan
on 6 Dec 2013
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!