MATLAB问题
function f =fun(x)f=0.44*x(1)+0.94*x(2)+0.88*x(3)+0.48*x(4)+4*x(5)+3.4*x(6)...
function f =fun(x)
f=0.44*x(1)+0.94*x(2)+0.88*x(3)+0.48*x(4)+4*x(5)+3.4*x(6)+2.3*x(7)+0.12*x(8)+11.6*x(9)+19*x(10)+25*x(11);
end
function [c,ceq]=nonlinearcondition(x)
c(1)=-3230*x(1)-2640*x(2)-2500*x(3)-1730*x(4)-2900*x(5)-2230*x(6)-2500*x(7)+2750;
c(2)=-8.27*x(1)-43*x(2)-40*x(3)-15.4*x(4)-62*x(5)-50*x(6)-45*x(7)+15;
c(3)=8.27*x(1)+43*x(2)+40*x(3)+15.4*x(4)+62*x(5)+50*x(6)+45*x(7)-16;
c(4)=-0.0038*x(1)-0.32*x(2)-0.32*x(3)-0.14*x(4)-3.91*x(5)-4.6*x(6)-33.4*x(8)-21*x(9)+2.85;
c(5)=0.0038*x(1)+0.32*x(2)+0.32*x(3)+0.14*x(4)+3.91*x(5)+4.6*x(6)+33.4*x(8)+21*x(9)-3;
c(6)=-0.058*x(1)-0.15*x(2)-0.14*x(3)-0.32*x(4)-2.9*x(5)-2.15*x(6)-0.14*x(8)-18.5*x(9)+0.5;
c(7)=0.058*x(1)+0.15*x(2)+0.14*x(3)+0.32*x(4)+2.9*x(5)+2.15*x(6)+0.14*x(8)+18.5*x(9)-0.55;
c(8)=-0.26*x(1)-2.45*x(2)-2.41*x(3)-0.54*x(4)-4.35*x(5)-3.28*x(6)-2.6*x(7)-99*x(11)+0.8;
c(9)=-0.125*x(1)-0.48*x(2)-0.51*x(3)-0.18*x(4)-1.65*x(5)-1.31*x(6)-0.65*x(7)-99*x(10)+0.31;
c(10)=-0.298*x(1)-1.08*x(2)-1.4*x(3)-0.58*x(4)-2.21*x(5)-1.74*x(6)-0.83*x(7)-99*x(10)+0.58;
c(11)=0.298*x(1)+1.08*x(2)+1.4*x(3)+0.58*x(4)+2.21*x(5)+1.74*x(6)+0.83*x(7)+99*x(10)-0.63;
c(12)=-0.077*x(1)-0.6*x(2)-0.6*x(3)-0.27*x(4)-0.8*x(5)-0.64*x(6)+0.19;
c(13)=-x(1)+0.5;
c(14)=x(1)-0.66;
c(15)=-x(2)-x(3)+0.1;
c(16)=x(2)+x(3)-0.22;
c(17)=-x(4)+0.04;
c(18)=x(4)-0.2;
c(19)=-x(5)-x(6)+0.03;
c(20)=x(5)+x(6)-0.07;
c(21)=x(7)-0.035;
ceq=x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+x(8)+x(9)+x(10)+x(11)-1;
[x,fval]=fminncon(‘fun ‘,[0],[],[],[],[],[0],[],’nonlinearcondition’)
function f =fun(x)
↑
错误: 此上下文中不允许函数定义。
为啥有错 展开
f=0.44*x(1)+0.94*x(2)+0.88*x(3)+0.48*x(4)+4*x(5)+3.4*x(6)+2.3*x(7)+0.12*x(8)+11.6*x(9)+19*x(10)+25*x(11);
end
function [c,ceq]=nonlinearcondition(x)
c(1)=-3230*x(1)-2640*x(2)-2500*x(3)-1730*x(4)-2900*x(5)-2230*x(6)-2500*x(7)+2750;
c(2)=-8.27*x(1)-43*x(2)-40*x(3)-15.4*x(4)-62*x(5)-50*x(6)-45*x(7)+15;
c(3)=8.27*x(1)+43*x(2)+40*x(3)+15.4*x(4)+62*x(5)+50*x(6)+45*x(7)-16;
c(4)=-0.0038*x(1)-0.32*x(2)-0.32*x(3)-0.14*x(4)-3.91*x(5)-4.6*x(6)-33.4*x(8)-21*x(9)+2.85;
c(5)=0.0038*x(1)+0.32*x(2)+0.32*x(3)+0.14*x(4)+3.91*x(5)+4.6*x(6)+33.4*x(8)+21*x(9)-3;
c(6)=-0.058*x(1)-0.15*x(2)-0.14*x(3)-0.32*x(4)-2.9*x(5)-2.15*x(6)-0.14*x(8)-18.5*x(9)+0.5;
c(7)=0.058*x(1)+0.15*x(2)+0.14*x(3)+0.32*x(4)+2.9*x(5)+2.15*x(6)+0.14*x(8)+18.5*x(9)-0.55;
c(8)=-0.26*x(1)-2.45*x(2)-2.41*x(3)-0.54*x(4)-4.35*x(5)-3.28*x(6)-2.6*x(7)-99*x(11)+0.8;
c(9)=-0.125*x(1)-0.48*x(2)-0.51*x(3)-0.18*x(4)-1.65*x(5)-1.31*x(6)-0.65*x(7)-99*x(10)+0.31;
c(10)=-0.298*x(1)-1.08*x(2)-1.4*x(3)-0.58*x(4)-2.21*x(5)-1.74*x(6)-0.83*x(7)-99*x(10)+0.58;
c(11)=0.298*x(1)+1.08*x(2)+1.4*x(3)+0.58*x(4)+2.21*x(5)+1.74*x(6)+0.83*x(7)+99*x(10)-0.63;
c(12)=-0.077*x(1)-0.6*x(2)-0.6*x(3)-0.27*x(4)-0.8*x(5)-0.64*x(6)+0.19;
c(13)=-x(1)+0.5;
c(14)=x(1)-0.66;
c(15)=-x(2)-x(3)+0.1;
c(16)=x(2)+x(3)-0.22;
c(17)=-x(4)+0.04;
c(18)=x(4)-0.2;
c(19)=-x(5)-x(6)+0.03;
c(20)=x(5)+x(6)-0.07;
c(21)=x(7)-0.035;
ceq=x(1)+x(2)+x(3)+x(4)+x(5)+x(6)+x(7)+x(8)+x(9)+x(10)+x(11)-1;
[x,fval]=fminncon(‘fun ‘,[0],[],[],[],[],[0],[],’nonlinearcondition’)
function f =fun(x)
↑
错误: 此上下文中不允许函数定义。
为啥有错 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询