yl122721400
2011-05-19, 09:57
利用文件编辑器为目标函数编写M文件(exefun.m)
function f=exefun(x)
f=671.175*(x(1)^2-x(2)^2)
5.2.2 编写约束条件M文件(execonfun.m)
function[c,ceq]=execonfun(x)
c(1)=1.2*10^5*(x(1)^2+x(2)^2)^0.5/4532355-2;
c(2)=1.2-1.2*10^5*(x(1)^2+x(2)^2)^0.5/4532355;
c(3)=8885.55*x(1)/(x(1)^4-x(2)^4)-300;
c(4)=3-x(1)+x(2);
ceq=[];
5.2.3 在MATLAB工具箱里调用程序fmincon求极值
x0=[55,50]
lb=[53;50]
ub=[59;56]
[x,fval,exitflag,output]=fmincon(@exefun,x0,[],[],[],[],lb,ub,@execonfun)
这个程序运行的时候出现下面错误
??? Error using ==> fmincon
FMINCON cannot continue because user supplied nonlinear constraint function
failed with the following error:
Error using ==> feval
Undefined function 'execonfun
请高手指教
function f=exefun(x)
f=671.175*(x(1)^2-x(2)^2)
5.2.2 编写约束条件M文件(execonfun.m)
function[c,ceq]=execonfun(x)
c(1)=1.2*10^5*(x(1)^2+x(2)^2)^0.5/4532355-2;
c(2)=1.2-1.2*10^5*(x(1)^2+x(2)^2)^0.5/4532355;
c(3)=8885.55*x(1)/(x(1)^4-x(2)^4)-300;
c(4)=3-x(1)+x(2);
ceq=[];
5.2.3 在MATLAB工具箱里调用程序fmincon求极值
x0=[55,50]
lb=[53;50]
ub=[59;56]
[x,fval,exitflag,output]=fmincon(@exefun,x0,[],[],[],[],lb,ub,@execonfun)
这个程序运行的时候出现下面错误
??? Error using ==> fmincon
FMINCON cannot continue because user supplied nonlinear constraint function
failed with the following error:
Error using ==> feval
Undefined function 'execonfun
请高手指教