我建立一個myfunction.m文件function f=myfuncion(x)M=[2,-1;-1,2];B=[3;-3];f=1/2*x'*M*x+B'*x;然后在matlab窗口中輸入 x0=[0;0];>> A=[];>> B=[];>> Aeq=[];>> Beq=[];>> lb=[-2;-2];>> ub=[2;2];>> x = fmincon('myfunction',x0,[],[],[],[],lb,ub)結果出現:Warning: Trust-region-reflective method does not currently solve this type of problem,using active-set (line search) instead.In fmincon at 422??? Error using ==> fmincon at 504FMINCON cannot continue because user supplied objective function failed with the following error:Undefined function or method 'myfunction' for input arguments of type 'double'.然后我用options = optimset('Algorithm','active-set');>> x = fmincon('myfunction',x0,[],[],[],[],lb,ub)還是不對,請大俠們指教!謝謝!
matlab中fmincon函數的用法?
慕尼黑8549860
2019-02-06 09:07:30