Symbolic Mathematics with Optimization Toolbox Solvers
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!