12.07.2015 Views

What Is Optimization Toolbox?

What Is Optimization Toolbox?

What Is Optimization Toolbox?

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

fminuncfunThefunctiontobeminimized. fun is a function that accepts a vector x andreturns a scalar f, the objective function evaluated at x. The function fun can bespecified as a function handle for an M-file functionx = fminunc(@myfun,x0)where myfun is a MATLAB function such asfunction f = myfun(x)f = ...% Compute function value at xfun can also be a function handle for an anonymous function.x = fminunc(@(x)norm(x)^2,x0);If the gradient of fun canalsobecomputedand the GradObj option is 'on',as set byoptions = optimset('GradObj','on')then the function fun must return, in the second output argument, the gradientvalue g, avector,atx. Note that by checking the value of nargout the functioncan avoid computing g when fun is called with only one output argument (in thecase where the optimization algorithm only needs the value of f but not g).function [f,g] = myfun(x)f = ...if nargout > 1g = ...end% Compute the function value at x% fun called with 2 output arguments% Compute the gradient evaluated at x8-77

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!