15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

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.

4 Function Functions<br />

The number <strong>of</strong> function evaluations, the number <strong>of</strong> iterations, and the<br />

algorithm are returned in the structure output when you provide fminbnd or<br />

fminsearch with a fourth output argument, as in<br />

or<br />

[x,fval,exitflag,output] = fminbnd(@humps,0.3,1);<br />

[x,fval,exitflag,output] = fminsearch(@three_var,v);<br />

Output Functions<br />

An output function is a function that an optimization function calls at each<br />

iteration <strong>of</strong> its algorithm. Typically, you might use an output function to<br />

generate graphical output, record the history <strong>of</strong> the data the algorithm<br />

generates, or halt the algorithm based on the data at the current iteration. You<br />

can create an output function as an M-file function, a subfunction, or a nested<br />

function.<br />

You can use the OutputFcn option with the following <strong>MATLAB</strong> optimization<br />

functions:<br />

• fminbnd<br />

• fminsearch<br />

• fzero<br />

This section covers the following topics:<br />

• “Creating and Using an Output Function” on page 4-15<br />

• “Structure <strong>of</strong> the Output Function” on page 4-16<br />

• “Example <strong>of</strong> a Nested Output Function” on page 4-17<br />

• “Fields in optimValues” on page 4-19<br />

• “States <strong>of</strong> the Algorithm” on page 4-20<br />

• “Stop Flag” on page 4-20<br />

4-14

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

Saved successfully!

Ooh no, something went wrong!