Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


Math Forum » Discussions » Software » comp.soft-sys.matlab

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

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Marcelo Marazzi

Posts: 24
Registered: 8/29/05
Re: Error using fmincon with NONLCON
Posted: Nov 16, 2005 11:25 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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!




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.