【发布时间】:2015-10-28 06:12:33
【问题描述】:
我的代码在运行时应正确使用拉格朗日乘数在此处找到函数的最大值/最小值:
clear all
syms x y L;
f = x^4+2*y^4;
g = x^2+5*y^2+2*y^2-10;
firstpart=jacobian(f,[x y])-L*jacobian(g,[x y]);
[Lsoln,xsoln,ysoln]=solve(firstpart,x^2+5*y^2+2*y^2-10);
subs(f,{x,y},{xsoln,ysoln})
% The coordinates that correspond with the greatest and smallest values
% above are the maximum and minimum, respectively.
但是,当我运行它时,我得到了四个错误:
Error using sym.getEqnsVars>checkVariables (line 92) 第二个 参数必须是符号变量的向量。
sym.getEqnsVars 中的错误(第 62 行) checkVariables(vars);
求解错误>getEqns(第 450 行)[eqns, vars] = sym.getEqnsVars(argv{:});
求解错误(第 225 行)[eqns,vars,options] = getEqns(varargin{:});
有人可以帮忙吗?
【问题讨论】:
标签: matlab