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 herey=(x(1)-1)^2+(x(2)-2)^2+(x(3)-3)^2+(x(4)-4)^2ff=optimset;ff.largerscale='off';ff.display='iter'
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/25 10:42:05
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 herey=(x(1)-1)^2+(x(2)-2)^2+(x(3)-3)^2+(x(4)-4)^2ff=optimset;ff.largerscale='off';ff.display='iter'
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)
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 herey=(x(1)-1)^2+(x(2)-2)^2+(x(3)-3)^2+(x(4)-4)^2ff=optimset;ff.largerscale='off';ff.display='iter'
错误提示说你至少得有3列,而你只有A,B两列?