为什么在matlab中用fmincon函数来解优化问题时!为什么我写的代码不显示x、fval、和flag的值求大神解答!

代码如下:%fminconfunctionmynamex0=20*rand(3,1);A=[];b=[];Aeq=[];beq=[];lb=[];beq=[];lb=[0... 代码如下:%fmincon
function myname
x0=20*rand(3,1);
A=[];b=[];
Aeq=[];beq=[];
lb=[];beq=[];
lb=[0;0;0];
ub=[20;20;20];
[x,fval,flag] = fmincon(@myobj,x0,A,b,Aeq,beq,lb,ub,@mycons);
function r = myobj(x)
r = 26*(x(1)-1)^2+50*x(2)+60*x(3);
r = -r;
function [c,ceq] = mycons(x)
c(1) = 10*x(1)^2+4*x(2)+3*x(3)^2-100;;
c(2) = 10-20*x(1)-x(2)-25*x(3);
c(3) = 20*x(1)+x(2)+25*x(3)-300;
ceq = [];

显示结果如下:
Warning: Trust-region-reflective method does not currently solve this type of problem,
using active-set (line search) instead.
> In fmincon at 439
In myname at 9
Local minimum found that satisfies the constraints.
Optimization completed because the objective function is non-decreasing in
feasible directions, to within the default value of the function tolerance,
and constraints were satisfied to within the default value of the constraint tolerance.
<stopping criteria details>
Active inequalities (to within options.TolCon = 1e-006):
lower upper ineqlin ineqnonlin
1 2 1
展开
 我来答
WM_THU
2013-08-21 · TA获得超过7164个赞
知道大有可为答主
回答量:4285
采纳率:80%
帮助的人:3938万
展开全部
[x,fval,flag] = fmincon(@myobj,x0,A,b,Aeq,beq,lb,ub,@mycons);
去掉行末的分号就可以显示了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式