24小时热门版块排行榜    

查看: 1001  |  回复: 0

mz1179

新虫 (初入文坛)

[求助] 求助各位大神看看我的程序问题在哪里?着急啊

各位大神,帮忙指导下!我用的fmincon函数优化,但是出现这种错误,各位帮忙看看我的程序哪里有问题,非常感谢。
目标函数:
function f=eg_mubiao(x)
f=pi*pi*x(1)^2*x(2)*x(3)/cos(x(4)*pi/180)/4;
约束条件:
function [g,ceq]=eg_yueshu(x)
g(1)=1.66*8*9.52/pi*(x(1)/x(2))^0.16*x(2)/x(1)^3-445;
g(2)=78000*x(1)^4/(8*x(2)^3*x(3))-1.213;
g(3)=8*9.52*x(2)^3*x(3)/(78000*x(1)^4)+x(1)*x(3)-0.4*x(2)*x(3);
g(4)=-(0.33*1520*x(1)^2.84+3.17*7.09*x(2)^0.84)/(4.23*9.52*x(2)^0.84)+1.5;
g(5)=-365000*x(1)/(x(3)*x(2)^3)+10*50;
g(6)=1.5*x(1)/x(2)+0.5*x(3)-5.3;
g(7)=1.1*x(1)+9.81/x(3)-pi*x(2)*tan(x(4)*pi/180);
ceq=[];
调用文件:
x0=[0.5,3.5,18,6.26];
A=[-14,1,0,0;4,-1,0,0;1,-1,0,0];
b=[0;0;-3];
lb=[0.5,3,2,5];
ub=[11,7,30,9];
[x,fn,exitflag,outflag]=fmincon(@eg_mubiao,x0,A,b,[],[],[],[],lb,ub,@eg_yueshu)

运行出现以下错误:
eg
Warning: Struct field assignment overwrites a value with class "double". See
MATLAB R14SP2 Release Notes, Assigning Nonstructure Variables As Structures
Displays Warning, for details.
> In fmincon at 378
  In eg at 6
Error using optimfcnchk (line 286)
NONLCON must be a function.


Error in fmincon (line 435)
   confcn =
   optimfcnchk(NONLCON,'fmincon',length(varargin),funValCheck,flags.gradconst,false,true);

Error in eg (line 6)
[x,fval,exitflag,outflag]=fmincon(@eg_mubiao,x0,A,b,[],[],[],[],lb,ub,@eg_yueshu)
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 mz1179 的主题更新
信息提示
请填处理意见