[問題]請問哪裡有錯(函數用法)已回收

看板MATLAB作者 (^^)時間16年前 (2009/02/11 17:23), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
這是help理的範例 我複製照著做 function [c, ceq] = confun(x) % Nonlinear inequality constraints c = [1.5 + x(1)*x(2) - x(1) - x(2); -x(1)*x(2) - 10]; % Nonlinear equality constraints ceq = []; 以上存在m.file裡 x0 = [-1,1]; % Make a starting guess at the solution options = optimset('LargeScale','off'); [x, fval] = ... fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options) 然後去跑...但出現Error using ==> fmincon FMINCON cannot continue because user supplied objective function failed with the following error: Error: File: C:\Program Files\MATLAB71\work\objfun.m Line: 13 Column: 1 Function definitions are not permitted at the prompt or in scripts. 我該如何修改? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.23.203.217
文章代碼(AID): #19afaFKg (MATLAB)
文章代碼(AID): #19afaFKg (MATLAB)