作业帮 > 综合 > 作业

matlab程序运行得不到x值?在线等!

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/11/08 22:53:24
matlab程序运行得不到x值?在线等!
function f=fun(x)
f=0.0393*x(1)*((x(2)+2*x(4))^2+(x(3))^2)^(0.5);
function [c,ceq]=mycon(x)
c(1)=90+10*0.4975-0.5*x(1)*(x(2)+10*x(3)+2*x(4));
c(2)=0.5*x(1)*(x(2)+10*x(3)+2*x(4))-275+25*0.4975;
c(3)=262465.2517*(0.5*x(1)*(x(2)+10*x(3)+2*x(4)))^(-1.5)-275+25*0.4975;
ceq=0;
x0=[2;9;2;0.6];
lb=[2;7.598;1;0.4749];
ub=[20;16.804;6;1.5754];
[x,fval,exitflag,output]=fmincon('fun',x0,[],[],[],[],lb,ub,'mycon');
qq:476393217
第1步.目标函数
在Matlab下输入:edit,然后将下面两行百分号之间的内容,复制进去,保存
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function f=fun(x)
f=0.0393*x(1)*((x(2)+2*x(4))^2+(x(3))^2)^(0.5);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
第2步.约束条件
在Matlab下输入:edit,然后将下面两行百分号之间的内容,复制进去,保存
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [c,ceq]=mycon(x)
c(1)=90+10*0.4975-0.5*x(1)*(x(2)+10*x(3)+2*x(4));
c(2)=0.5*x(1)*(x(2)+10*x(3)+2*x(4))-275+25*0.4975;
c(3)=262465.2517*(0.5*x(1)*(x(2)+10*x(3)+2*x(4)))^(-1.5)-275+25*0.4975;
ceq=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
第3步.求解
在Matlab下面输入:
x0=[2;9;2;0.6];
lb=[2;7.598;1;0.4749];
ub=[20;16.804;6;1.5754];
[x,fval,exitflag,output]=fmincon('fun',x0,[],[],[],[],lb,ub,'mycon');