nonlcon : Too many input arguments.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Matt J
le 8 Déc 2012
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 commentaires
Matt J
le 8 Déc 2012
Modifié(e) : Matt J
le 8 Déc 2012
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
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!