matlab中fmincon函数求解极值
目标函数y=-12.237-2.210x2x2+119.165x2+232.563x5-16.230x1x3-15.124x1x4-52.029x2x3-5.732x3x...
目标函数 y=-12.237-2.210x2x2+119.165x2+232.563x5-16.230x1x3-15.124x1x4-52.029x2x3-5.732x3x4
约束条件 x1=[0,1];x2=[0,1];x3=[1,10];x4=[0,1];x5=[0,1]; 展开
约束条件 x1=[0,1];x2=[0,1];x3=[1,10];x4=[0,1];x5=[0,1]; 展开
展开全部
试一下:
function y=fun_14(x)
y=-12.237-2.210*x(2)^2+119.165*x(2)+232.563*x(5)-16.230*x(1)*x(3)-15.124*x(1)*x(4)-52.029*x(2)*x(3)-5.732*x(3)*x(4);
新建.m文件:
clc,clear
x0=zeros(1,5);
lb=[0 0 1 0 0]';ub=[1 1 10 1 1]';
options=optimset('Largescale','off');
[x,feval,exitflag]=fmincon('fun_14',x0,[],[],[],[],lb,ub,'',options)
结果:
x =
1 1 10 1 0
feval =
-650.3160
exitflag =
1
>>
function y=fun_14(x)
y=-12.237-2.210*x(2)^2+119.165*x(2)+232.563*x(5)-16.230*x(1)*x(3)-15.124*x(1)*x(4)-52.029*x(2)*x(3)-5.732*x(3)*x(4);
新建.m文件:
clc,clear
x0=zeros(1,5);
lb=[0 0 1 0 0]';ub=[1 1 10 1 1]';
options=optimset('Largescale','off');
[x,feval,exitflag]=fmincon('fun_14',x0,[],[],[],[],lb,ub,'',options)
结果:
x =
1 1 10 1 0
feval =
-650.3160
exitflag =
1
>>
追问
本人菜鸟,可用qq联系交流不
追答
929675716
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询