The Math Forum

Search All of the Math Forum:

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

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

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

Topic: Fmincon Help with more than one input variable
Replies: 1   Last Post: Feb 20, 2013 2:52 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Alan Weiss

Posts: 1,430
Registered: 11/27/08
Re: Fmincon Help with more than one input variable
Posted: Feb 20, 2013 2:52 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 2/20/2013 1:17 PM, Lucas wrote:
> I have been using MATLAB on and off, but recently started using the
> optimization toolbox. Long store short, I have been having trouble
> with the fmincon functions. I can post my code to show the function i
> have been using:
> function RMS_T = User_Define(phi,psi)
> phi_u = phi(1)*(pi/180); % angle for probe two psi_u =
> psi(1)*(pi/180); % angle for probe three

> **snip**

> [x,fval] = fmincon(@User_Define,x0,[],[],[],[],lb,ub,[],options);
> but I keep getting an error of Error using User_Define
> Too many output arguments.
> Error in fmincon (line 610)
> [initVals.f,initVals.g(:)] = feval(funfcn{3},X,varargin{:});
> Error in Angle_Opt (line 13)
> [x,fval] = fmincon(@User_Define,x0,[],[],[],[],lb,ub,[],options);
> Caused by:
> Failure in initial user-supplied objective function evaluation.
> cannot continue..
> Any help or advice would be welcome. Thank You

fmincon wants all the parameters it controls to be in one vector,
usually called x. In your case, change your function as follows:

function RMT_T = User_Define(x)
phi = x(1);
psi = x(2);
% rest of the code is exactly the same as before

Alan Weiss
MATLAB mathematical toolbox documentation

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.