Symbolic Mathematics with Optimization Toolbox Solvers
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
In this http://www.mathworks.com/help/optim/examples/using-symbolic-mathematics-with-optimization-toolbox-solvers.html is given the documentation for using Symbolic Mathematics with Optimization Toolbox Solvers. The first example is this:
syms x1 x2 real
x = [x1;x2]; % column vector of symbolic variables
f = log(1 + 3*(x2 - (x1^3 - x1))^2 + (x1 - 4/3)^2);
gradf = jacobian(f,x).'; % column gradf
hessf = jacobian(gradf,x);
fh = matlabFunction(f,gradf,hessf,'vars',{x});
options = optimset('GradObj','on','Hessian','on', ...
'Display','final');
[xfinal fval exitflag output] = fminunc(fh,[-1;2],options)
The function handle fh that is created accepts one matrix input which is:
in1(1,:)
in1(2,:)
The optimization used in the example did not require any constraints. However if constraints were necessary then they should be given in the form of a two dimensional matrix.
The constraints in the example would require a 3 dimensional matrix to be defined. But then the optimization would not be able to be executed since the solvers accept 2 dimensional matrices.
My question is how must the matlabFunction be written in order to create a function handle which would accept as an input variable a vector of x, such as:
in1(1)
in1(2)
Thank you
0 commentaires
Réponses (2)
Giorgos Papakonstantinou
le 1 Fév 2013
Modifié(e) : Giorgos Papakonstantinou
le 1 Fév 2013
0 commentaires
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!