Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
NCTM or The Math Forum.



Re: Error using fmincon with NONLCON
Posted:
Nov 16, 2005 11:25 AM


I've just run the code in the doc page you mention (I post the code at the end of the message), and it runs with no errors, returning the answer provided in the doc.
Please compare your code with the code below and see if there's something missing.
marcelo
%%%%%%%%%%%%%%%%%%% begin mydriver.m % mydriver is defined as a function so as to be able % to use subfunctions, and thus have everything % (objective, constraints, call to fmincon) in one file. function mydriver
x0 = [1,1]; % Make a starting guess at the solution options = optimset('LargeScale','off'); [x, fval] = ... fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options)
% subfunctions function f = objfun(x) f = exp(x(1))*(4*x(1)^2 + 2*x(2)^2 + 4*x(1)*x(2) + 2*x(2) + 1);
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 = []; %%%%%%%%%%%%%%%% end mydriver.m
Ingrid Måge wrote: > Hi, > > I have a problem using fmincon. I get the following error message: > > ??? Error using ==> optimfcnchk > Too many input arguments. > > Error in ==> fmincon at 260 > [confcn, msg] = > optimfcnchk(NONLCON,'fmincon',length(varargin),funValCheck,gradconstfl > ag,false,1); > > I even get the error when I'm using the example from the optimisation > tutorial, so there shouldn't be anything wrong with my functions or > input. (http://www.mathworks.com/access/helpdesk/help/toolbox/optim/ug/f10912.html) > > I'm using version 7.1 (R14). > > I'll be very grateful if anyone can help me!



