Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Optimizing a function consisting of other variables

Asked by Fred on 14 Oct 2012

Hello, I have a function as this:

function l=L2(u1, u2, w, x) l = -sum(log(((log(u1).*log(u2)).^(-1+x)).*((w.^((2-2*x)/x))-(1-x.*(w.^(1-2*x)/2)))./(u1.*u2.*exp(w.^(1/x))))); end

which u1, u2, w are 40*1 vectors, and I want to optimize this for min of x with optimtool but his gives me the error of

Error in the following problem input(s): objective: Not enough input arguments.

Can anybody help me?

1 Comment

Matt J on 14 Oct 2012

Show more code, in particular, the solver that you're using and the code you use to call it.

Also, use markup to make the code you post more readable, including the code in your Question.

Fred

Products

1 Answer

Answer by Alan Weiss on 15 Oct 2012
Accepted answer

Your question might be about how to include extra parameters. See this link.

Alan Weiss

MATLAB mathematical toolbox documentation

2 Comments

Matt Tearle on 15 Oct 2012
u1 = ...
u2 = ...
w  = ...
objfun = @(x) L2(u1,u2,w,x) % define a function of x with u1, u2, w fixed

Now use objfun as your objective function.

Fred on 15 Oct 2012

Thank you for both answers

Alan Weiss

Contact us