<>先定义两个函数:</P>
<>function f=fun(x)<BR>f=exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1);</P>
<>function[g,ceq]=mycon2(x)<BR>g=[x(1)+x(2);1.5+x(1)*x(2)-x(1)-x(2);-x(1)*x(2)-10];</P>
<P>然后运行脚本文件:</P>
<P>x0=[-1;1];<BR>A=[];<BR>b=[];<BR>Aeq=[1 1];<BR>beq=[0];<BR>vlb=[];<BR>vub=[];</P>
<P>[x,fval]=fmincon('fun',x0,[],[],Aeq,beq,vlb,vub,'mycon2');</P>
<P>显示错误如下:</P>
<P>>> Warning: Large-scale (trust region) method does not currently solve this type of problem,<BR>switching to medium-scale (line search).<BR>> In E:\Matlab6.5\toolbox\optim\fmincon.m at line 213<BR> In E:\Matlab6.5\work\练习\jiaoben.m at line 9<BR>??? Error using ==> fmincon<BR>FMINCON cannot continue because user supplied nonlinear constraint function<BR> failed with the following error:</P>
<P>One or more output arguments not assigned during call to 'feval'.</P>
<P>Error in ==> E:\Matlab6.5\work\练习\jiaoben.m<BR>On line 9 ==> [x,fval]=fmincon('fun',x0,[],[],Aeq,beq,vlb,vub,'mycon2');</P>
<P>请高手指点一下,这个错误到底事怎么回事啊!</P> |