Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: Fmincon Help with more than one input variable
Posted:
Feb 20, 2013 2:52 PM
|
|
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. > FMINCON > 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
|
|
|
|