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!