[求助]程序出错了
约束条件文件function [c,ceq]=mycon(x)
c(1)=6*5660*x(3)/(0.09*4*x(1)^2)-500*10^6;
if x(3)>(x(4)-0.045)*(2*x(1)/x(2)-1)
q=1.5*5660*(x(2)-x(1))*((x(4)-x(3)-0.045)/(x(2)-x(1)))^2/(0.09*4*(x(1)*(x(4)-0.045)-x(2)*0.045);
else
q=6*5660*(x(4)-0.045)/(0.09*4*x(2)^2);
c(2)=q-500*10^6;
end ;
k=6*2.1*10^11*0.92*4*0.09*x(2)^3/(12*x(4)^3*(1+((x(4)-0.045)/x(4))^3)*(1-2*(x(3)/(x(4)-0.045))^1.5)+(x(3)/X(4))^3*(x(2)/x(1)));
c(3)=fabs((k-73500)/73500-0.005;
ceq=0;
A=[-1 0 0 0
0 1 0 0
1 -1 0 0
0 0 -1 0
0 0 0 1];
b=[0.0083;0.02;-0.001;0;0.6];
目标函数文件
function f=myfun(x)
f=2*7.8*10^3*9.8*0.09*4*(x(1)*x(3)+(x(4)-x(3)-0.045)*(x(1)+x(2))/2+x(2)*0.045)
命令窗口的命令
b=[0.0083;0.02;-0.001;0;0.6];
A=[-1 0 0 0
0 1 0 0
1 -1 0 0
0 0 -1 0
0 0 0 1];
x0=[0.01;0.025;0.04;0.6];
lb=zeros(4,1);
[x,fval,exitflag,output,lambda]=fmincon(@opt0202514_o,x0,A,b,[],[],[],[],@opt_0202514_c)
Warning: Large-scale (trust region) method does not currently solve this type of problem,
switching to medium-scale (line search).
> In fmincon at 271
??? Error using ==> fmincon
FMINCON cannot continue because user supplied nonlinear constraint function
failed with the following error:
Error using ==> feval
Undefined command/function 'opt_0202514_c'.