作业帮 > 综合 > 作业

Error using fmincon (line 300) A must have 3 column(s).

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/13 00:43:27
Error using fmincon (line 300) A must have 3 column(s).
function y =opt_fun1(x)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
y=(x(1)-1)^2+(x(2)-2)^2+(x(3)-3)^2+(x(4)-4)^2
ff=optimset;ff.largerscale='off';ff.display='iter';ff.tolfun=1e-30;ff.tolx=1e-15;
ff.tolcon=1e-20;x0=[1;1;1];A=[1,1,1,1;3,3,2,1;0,0,0,0];B=[5;10];xm=[0,0,0,0];xM=[];Aeq=[];Beq=[];
[x,f_opt,c,d]=fmincon('opt_fun1',x0,A,B,Aeq,Beq,xm,xM,'opt_con1',ff)
错误提示说你至少得有3列,而你只有A,B两列?