跪求各位大大解决下MATLAB优化中的燃眉之急 ??? Attempt to execute SCRIPT fmincon as a function:

???AttempttoexecuteSCRIPTfminconasafunction:F:\毕业设计\设计正文\fmincon.mErrorin==>fminconat... ??? Attempt to execute SCRIPT fmincon as a function:
F:\毕业设计\设计正文\fmincon.m

Error in ==> fmincon at 6
[x,fval,exitflag,output] = fmincon('exefun',x0,[],[],[],[],lb,ub,'execonfun',options);
原程序是
function f = exefun(x)
f = x(0)*42;

function [c,ceq] = execonfun(x)
c=[ 1-(35-2.5)*x(0)/(28+8+4*x(0));
2.5*189*(1.718*63.69/(10*x(0)*35*x(0)))^(1/2)/750-1;
1.718*63.69*2.45*1.65/(10*x(0)*600)-1;];
ceq = [];

x0=(2);
lb=(1.75);
ub=(6);
options = optimset('LargeScale','off');
[x,fval,exitflag,output] = fmincon('exefun',x0,[],[],[],[],lb,ub,'execonfun',options);
展开
 我来答
酷呆爱死呆
2011-04-21 · TA获得超过4240个赞
知道大有可为答主
回答量:507
采纳率:100%
帮助的人:1155万
展开全部
function f = exefun(x)
f = x(1)*42;%%x的索引数是从1开始的
%%%%%%%%%%%%%%%%%
function [c,ceq] = execonfun(x)
c=[ 1-(35-2.5)*x(1)/(28+8+4*x(1));
2.5*189*(1.718*63.69/(10*x(1)*35*x(1)))^(1/2)/750-1;
1.718*63.69*2.45*1.65/(10*x(1)*600)-1;];
ceq = []; %%下面一样,x(0)改为x(1)
%%%%%%%%%%%%%%%%%%%%%%%%%%
>> x0=[2];%%x0是初值,你的代码只有一个变量,所以x0就一个值,中括号
lb=1.75;
ub=6;%%不用加括号
options = optimset('LargeScale','off');
[x,fval,exitflag,output] = fmincon('exefun',x0,[],[],[],[],lb,ub,'execonfun',options);
Optimization terminated: first-order optimality measure less
than options.TolFun and maximum constraint violation is less
than options.TolCon.
Active inequalities (to within options.TolCon = 1e-006):
lower upper ineqlin ineqnonlin
1
追问
先谢谢你的回答  呵呵 请问后面这些是程序上面的还是说明 全部写入么 
Optimization terminated: first-order optimality measure less 。。。
我全部输入后的结果是
??? Attempt to execute SCRIPT fmincon as a function:
F:\毕业设计\设计正文\fmincon.m
Error in ==> fmincon at 5
[x,fval,exitflag,output] = fmincon('exefun',x0,[],[],[],[],lb,ub,'execonfun',options);
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式