问题
1 objfun的;改为半角;
2matlab 不识别 confun中ln 改为log
3fmincon vlb vub没定义 改为lb ub
----------------------------
function f=objfun(x)
f=pi*(4.14*x(1)+2.5)^2*x(2)*x(3)^2/4;
--------------------------------------
function [c,ceq]=confun(x)
c=[6.35*10^5-x(1)^2*x(2)*x(3)^2;13432.29*(4.69-0.63*log(x(1)))-x(1)*x(2)*x(3)^2];
ceq=[];
-------------------------------------
上面两个函数存为.m文件
命令窗口输入
A=[0 -1 5;0 1 -17];
b=[0;0];
lb=[17;10;2];
ub=[50;100;6];
x0=[17;87;5];
[x,fval]=fmincon(@objfun,x0,A,b,[],[],lb,ub,@confun)
Warning: Trust-region-reflective algorithm does not solve this type of problem, using
active-set algorithm. You could also try the interior-point algorithm: set the
Algorithm option to 'interior-point' and rerun.
> In fmincon at 460
Local minimum possible. Constraints satisfied.
fmincon stopped because the size of the current search direction is less than
twice the default value of the step size tolerance and constraints were
satisfied to within the default value of the constraint tolerance.
Active inequalities (to within options.TolCon = 1e-006):
lower upper ineqlin ineqnonlin
1 2
x =
17.000000000000000
86.941482536032794
5.138256344408354
fval =
9.575582120628687e+006
再问: 我按照你的写,可还是说: ??? Attempt to execute SCRIPT fmincon as a function. 会不会是我的软件有问题?
再答: 你的是什么版本 的,要不QQ聊吧
再问: matlab 7.0。你的QQ?