Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Error using fmincon with NONLCON
Replies: 3   Last Post: Nov 17, 2005 2:50 AM

 Messages: [ Previous | Next ]
 Marcelo Marazzi Posts: 24 Registered: 8/29/05
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] =
> 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!

Date Subject Author
11/16/05 Ingrid Måge
11/16/05 Marcelo Marazzi
11/17/05 Ingrid Måge
11/17/05 Ingrid Måge