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.

lsqnonlinfunThe function whose sum of squares is minimized. fun is afunction that accepts a vector x and returns a vector F, theobjective functions evaluated at x. The function fun can bespecified as a function handle for an M-file functionx = lsqnonlin(@myfun,x0)where myfun is a MATLAB function such asfunction F = myfun(x)F = ...% Compute function values at xfun can also be a function handle for an anonymousfunction.x = lsqnonlin(@(x)sin(x.*x),x0);If the user-defined values for x and F are matrices, they areconverted to a vector using linear indexing.If the Jacobian can also be computed and the Jacobianoption is 'on', setbyoptions = optimset('Jacobian','on')then the function fun must return, in a second outputargument, the Jacobian value J, amatrix,atx. Notethat by checking the value of nargout the function canavoid computing J when fun is called with only one outputargument (in the case where the optimization algorithmonly needs the value of F but not J).function [F,J] = myfun(x)F = ...% Objective function values at xif nargout > 1 % Two output argumentsJ = ... % Jacobian of the function evaluated at xend8-168optionsIf fun returns a vector (matrix) of m components and x haslength n, wheren is the length of x0, then the Jacobian J isan m-by-n matrix where J(i,j) is the partial derivative ofF(i) with respect to x(j). (Note that the Jacobian J is thetranspose of the gradient of F.)“Options” on page 8-170 provides the function-specificdetails for the options values.

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

Saved successfully!

Ooh no, something went wrong!