realyw
2009-02-11, 10:43
利用fimincon求解有约束的非线性优化问题出错
如下:
function f=myfunction(x)
f=-x(1)*x(2)*x(3);
在命令窗口输入
>> A=[-1 -2 -2;1 2 2];
>> b=[0;72];
>> x0=[10;10;10];
>> [x,fval] = fmincon(@myfunction,x0,A,b)
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 274
??? Error using ==> fmincon
FMINCON cannot continue because user supplied objective function failed with the following error:
Undefined function or variable 'b'.
最近在学MATLAB,这是fmincon命令help中的一个例子,请问各位大侠为什么会这样呢?
如下:
function f=myfunction(x)
f=-x(1)*x(2)*x(3);
在命令窗口输入
>> A=[-1 -2 -2;1 2 2];
>> b=[0;72];
>> x0=[10;10;10];
>> [x,fval] = fmincon(@myfunction,x0,A,b)
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 274
??? Error using ==> fmincon
FMINCON cannot continue because user supplied objective function failed with the following error:
Undefined function or variable 'b'.
最近在学MATLAB,这是fmincon命令help中的一个例子,请问各位大侠为什么会这样呢?