ykpdesky 发表于 2008-4-11 17:14

One or more output arguments not assigned during call... 出错求助

我是个菜鸟,按照书上的例子学习使用优化工具箱.
完全按照书上的方法输入下列程序.
首先,编写一个叫opt17_7o.m的文件,具体如下:
function f = myfun(x)
f=0.192457*1e-4*(x(2)+2)*x(1)^2*x(3);
然后,再编写一个叫opt17_7c.m的文件,具体如下:
function =mycon(x)
c(1)=350-163*x(1)^(-2.86)*x(3)^0.86;
c(2)=10-0.4*0.01*x(1)^(-4)*x(2)*x(3)^3;
c(3)=(x(2)+1.5)*x(1)+0.44*0.01*x(1)^(-4)*x(2)*x(3)^3-3.7*x(3);
c(4)=375-0.356*1e6*x(1)*x(2)^(-1)*x(3)^(-2);
c(5)=4-x(3)/x(1);

最后在命令窗口中输入:
A =[ -1   0   0
      1   0   0
      0    -1   0
      0   1   0
      0   0    -1
      0   0   1];
b=[-1;4;-4.5;50;-10;30];
x0=
lb=zeros(3,1);
=fmincon(@opt17_7o,x0,A,b,[],[],lb,[],@opt17_7c)

按照书上的说法,应该得出一个优化的结果,可是我输入后,却提示我有下面的错误:
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 260
??? Error using ==> fmincon
FMINCON cannot continue because user supplied nonlinear constraint function
failed with the following error:
One or more output arguments not assigned during call to 'C:\MATLAB7\work\opt17_7c.m (opt17_7c)'.

我琢磨半天,实在不知道要怎么解决,因为是原本照书上套的程序,为什么在我机子上就不能运行呢?很烦恼啊!求各位高手鼎立相助!谢谢!

[ 本帖最后由 eight 于 2008-4-14 20:47 编辑 ]

sigma665 发表于 2008-4-12 09:38

function =mycon(x)
c(1)=350-163*x(1)^(-2.86)*x(3)^0.86;
c(2)=10-0.4*0.01*x(1)^(-4)*x(2)*x(3)^3;
c(3)=(x(2)+1.5)*x(1)+0.44*0.01*x(1)^(-4)*x(2)*x(3)^3-3.7*x(3);
c(4)=375-0.356*1e6*x(1)*x(2)^(-1)*x(3)^(-2);
c(5)=4-x(3)/x(1);

这个里的参数是不是输出太多了,改一个试试呢

ceq是什么,里面根本没有用到

eight 发表于 2008-4-14 20:48

原帖由 ykpdesky 于 2008-4-11 17:14 发表 http://www.chinavib.com/forum/images/common/back.gif
我是个菜鸟,按照书上的例子学习使用优化工具箱.
完全按照书上的方法输入下列程序.
首先,编写一个叫opt17_7o.m的文件,具体如下:
function f = myfun(x)
f=0.192457*1e-4*(x(2)+2)*x(1)^2*x(3);
然后,再编写一个叫 ... 这个问题早就已经整理到 常见错误 贴中,请在置顶帖中找答案
页: [1]
查看完整版本: One or more output arguments not assigned during call... 出错求助