im trying to use lagrange multipliers to find mins and maxs and this is the code i wrote
syms x y L; f=(x^2)*y; g=x+(y^2)-16;
T=jacobian(f,[x y])-L*jacobian(g,[x y]);
[xsoln,ysoln,Lsoln]=solve(T,g)
im getting the following error messages:
Error using sym.getEqnsVars>checkVariables (line 92)
The second argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 62)
checkVariables(vars);
Error in solve>getEqns (line 450)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in solve (line 225)
[eqns,vars,options] = getEqns(varargin{:});

 채택된 답변

KSSV
KSSV 2016년 10월 20일
편집: KSSV 2016년 10월 20일

0 개 추천

You have to specify for what variable in T has to be solved.
Use
[xsoln,ysoln,Lsoln]=solve(T,[L,x,y])
The above solves for L,x,y
[xsoln,ysoln]=solve(T,[x,y])
The above solves for x,y, in terms of L.
Read the documentation part.

댓글 수: 1

Walter Roberson
Walter Roberson 2016년 10월 20일
If you were thinking that you were solving for g, then you cannot do that: it is only possible to solve for variables, not for expressions.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2016년 10월 20일

댓글:

2016년 10월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by