필터 지우기
필터 지우기

nonlcon : Too many input arguments.

조회 수: 2 (최근 30일)
mklcst mklcst
mklcst mklcst 2012년 12월 8일
Hi everybody, I have a problem with non linear constraints in fmincon. I get this error "Too many input arguments".
The nonlcon function is very simple:
function [c,ceq] = covposdef(x)
c = -x(3)*x(5)+x(4)^2;
ceq = [];
end
The function to optimize is a likelihood of a bivariate normal density. Any suggestion?
  댓글 수: 2
Matt J
Matt J 2012년 12월 8일
편집: Matt J 2012년 12월 8일
Are you sure it's coming from nonlcon? Copy/paste the complete error message.
mklcst mklcst
mklcst mklcst 2012년 12월 8일
Error using covposdef
Too many input arguments.
Error in fmincon (line 718)
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
Error in meancovarianceest (line 16)
theta = fmincon(@meancov,iv,[],[],[],[],lb,ub,@covposdef,options,data);
Caused by:
Failure in initial user-supplied nonlinear constraint function evaluation. FMINCON
cannot continue.

댓글을 달려면 로그인하십시오.

채택된 답변

Matt J
Matt J 2012년 12월 8일
I think the problem is that FMINCON thinks your fixed "data" is meant to be passed both to meancov and covposdef. If you intend only to pass it to meancov, call FMINCON using the following more modern syntax
theta = fmincon(@(x) meancov(x,data),iv,[],[],[],[],lb,ub,@covposdef,options);
  댓글 수: 2
mklcst mklcst
mklcst mklcst 2012년 12월 8일
Thank you, it's working but I obtain different results when I use (even without nonlcon)
@(x) meancov(x,data)
Can you tell me how it works @(x)?
Matt J
Matt J 2012년 12월 8일
편집: Matt J 2012년 12월 8일
You'll want to read the doc on Anonymous Functions, but basically they're a way of defining functions on-the-fly, possibly with fixed parameters, e.g.,
>> fixed=2; f=@(x) x+fixed;
>> f(10), f(20), f(30)
ans =
12
ans =
22
ans =
32

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Solver-Based Nonlinear Optimization에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by