fmincon function weird error
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
Hello,
I am wondering why am I getting this weird error:
Error using myfun
Too many input arguments.
Error in fmincon (line 631)
initVals.f = feval(funfcn{3},X,varargin{:});
Although my function myfun has only one argument that is x, but looks like the implementation of fmincon calls it with 3!
Help please
回答 (1 件)
Matt J
2013 年 4 月 27 日
0 投票
The varargin{:} that you are passing to FMINCON are being passed to myfun and mycon as extra arguments. However, the input signature of these functions is written only to accept a single input argument x.
If the extra varargin parameters are not needed by your objective/constraints, then remove them. If they are needed, then passing them through varargin is an outdated method. See here for the newer techniques
2 件のコメント
seldeeno
2013 年 4 月 27 日
I'm talking about FMINCON. If you don't want FMINCON to send extra parameters to myfun, then don't call FMINCON with those extra parameters,
[temppop,tempval,exitflag,output] = fmincon(@myfun,xx,[],[],[],[],...
XRmin(1,:),XRmax(1,:),@mycon,opts); %omit varargin{:}
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!