登录论坛

查看完整版本 : [MATLAB基础] 程序错误,求助


sxhzwjls
2015-09-11, 23:04
R2010b版本,运行下面程序错误,请指导,谢谢。
jsq_f.m
function f=jsq_f(x);
f=0.67+pi*(x(3)+2)*x(2)^3*((21*x(1)+2+6/(x(1)+2))^2-(21x(1)-6.4)^2)/4;


jsq_y.m
function[c,ceq]=jsq_y(x);
c(1)=20552.7/x(1)^2-x(2)^3*x(3);
c(2)=229400*x(1)^2*sqrt(1.3814*(x(1)/x(2))^2+0.132474)-x(2)^3*(x(3)-2.4)^4;
c(3)=0.85-0.95*x(1)*(X(3)-X(1)*0.024)/(x(1)*x(3)+0.024*x(3)^2);
c(4)=2659574/(x(2)*(x(3)+21*x(1)))^1.75-60;
ceq=[];


jsq_fy.m
x0=[2;8;10];
ib=[2;2;8];
ub=[3.81;16;18];
a=zeros(6,3);
a(1,1)=-1;a(2,1)=1;
a(3,2)=-1;a(4,2)=1;
a(5,3)=-1;a(6,3)=1;
b=[-2;3.81;-2;16;-8;18];
[x,fval]=fmincon(@jsq_f,x0,a,b,[],[],ib,ub,@jsq_y);
Warning: Trust-region-reflective algorithm does not solve this type of problem, using active-set algorithm. You could also try the interior-point or sqp algorithms: set the
Algorithm option to 'interior-point' or 'sqp' and rerun. For more help, see Choosing the Algorithm in the documentation.
> In fmincon at 472
??? Undefined function or method 'X' for input arguments of type 'double'.

Error in ==> jsq_y at 4
c(3)=0.85-0.95*x(1)*(X(3)-X(1)*0.024)/(x(1)*x(3)+0.024*x(3)^2);

Error in ==> fmincon at 654
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});

Caused by:
Failure in initial user-supplied nonlinear constraint function evaluation. FMINCON cannot continue.