12.07.2015 Views

What Is Optimization Toolbox?

What Is Optimization Toolbox?

What Is Optimization Toolbox?

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

fminconfunThe function to be minimized. fun is a function that accepts a vector x andreturns a scalar f, the objective function evaluated at x. The function funcan be specified as a function handle for an M-file functionx = fmincon(@myfun,x0,A,b)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 = fmincon(@(x)norm(x)^2,x0,A,b);If the gradient of fun can also be computed and the GradObj option is 'on',as set byoptions = optimset('GradObj','on')then the function fun must return, in the second output argument, thegradient value g, avector,atx. Note that by checking the value of nargoutthe function can avoid computing g when fun is called with only one outputargument (in the case where the optimization algorithm only needs thevalue of f but not g).function [f,g] = myfun(x)f = ...% Compute the function value at xif nargout > 1 % fun called with two output argumentsg = ... % Compute the gradient evaluated at xendThe gradient consists of the partial derivatives of f at the point x. Thatis, the ith component of g is the partial derivative of f with respect to theith component of x.8-37

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

Saved successfully!

Ooh no, something went wrong!