Problem with fmincon: nonlcon
Afficher commentaires plus anciens
fmincon runs fine without the non-linear constraint given by the function:
function [c,ceq] = DiagCAW11_constraints(theta,RC,r,bsum)
A=diag(theta(11:14),0);
B=diag(theta(15:18),0);
ceq = [];
c = diag(A.^2 + B.^2 - 1);
end
However when running with the constraint, I get the error
"Error using DiagCAW11_constraints
Too many input arguments."
Here is the entire minimization problem:
fmincon('DiagCAW11_likelihood',theta0,[],[],[],[],[],lb,ub,'DiagCAW11_constraints',options,RC,r,bsum);
Réponses (1)
Are Mjaavatten
le 14 Août 2016
To transfer the extra inputs to DiagCAW11_constraints you should use an anonymous function:
Make sure that RC, r, bsum are defined. Then define an anonymous function nonlcon as:
nonlcon = @(theta) DiagCAW11_constraints(theta,RC,r,bsum);
You may transfer parameters to DiagCAW11_likelihood in the same manner:
likelihood = @(theta) DiagCAW11_likelihood(theta,par1,par2)
Now you may call fmincon:
theta = fmincon(likelihood,theta0,[],[],[],[],lb,ub,nonlcon,options);
Good luck!
Catégories
En savoir plus sur Linear Least Squares dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!