[求助]这个matlab优化程序哪里有问题
<P align=left>这可是书上的例子,怎么我的matlab老是报错: <BR>Error using ==> fmincon <BR>FMINCON cannot continue because user supplied objective function <BR> failed with the following error: <BR>Error using ==> feval <BR>Undefined function 'fun61'. <BR><BR>程序如下 <BR>function f=fun61(x) <BR>f=-1500*x(1)-1200*x(2)-1800*x(3); <BR>%不等式约束 <BR>A=; <BR>b=; <BR>%等式约束 <BR>Aeq=; <BR>beq=; <BR>%边界约束 <BR>lb=; <BR>ub=; <BR>%标准算法 <BR>options=optimset('largescale','off'); <BR>%初始点 <BR>x0=; <BR>%优化函数调用 <BR>=fmincon('fun61',x0,A,b,Aeq,beq,lb,ub,[],options); <BR></P> 这个 function 是不是要和主程序分开来呢? 要写成两个文件? <P>将function写到m文件中,<BR>其他的直接在command下运行即可。<BR><BR>试了一下,也是没法求解。<BR>如下所示:<BR>>> A=; <BR>>> b=; <BR>>> Aeq=; <BR>>> beq=; <BR>>> lb=; <BR>>> ub=; <BR>>> options=optimset('largescale','off'); <BR>>> x0=; <BR>>> =fmincon('fun61',x0,A,b,Aeq,beq,lb,ub,[],options); <BR>Optimization terminated: magnitude of search direction less than 2*options.TolX<BR> and maximum constraint violation is less than options.TolCon.<BR>Active inequalities (to within options.TolCon = 1e-006):<BR>lower upper ineqlin ineqnonlin<BR> 2 1 <BR> 2 <BR> 3 <BR>>> <BR><BR><BR>估计程序本身有点问题。<BR>自己再研究研究吧。</P> <P>忘了说运行环境:<BR>matlab version:<BR>7.0.1.24704(R14)Service Pack1</P>
页:
[1]