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.

<strong>Optimization</strong> OptionsStopping an <strong>Optimization</strong> Based on Data in optimValues. The outputfunction can stop an optimization at any iteration based on the current datain optimValues. For example, the following code sets stop to true if thedirectional derivative is less than .01:function stop = outfun(x, optimValues)stop = false;% Check if directional derivative is less than .01.if optimValues.directionalderivative < .01stop = true;endStopping an <strong>Optimization</strong> Based on GUI Input. If you design a GUI toperform optimizations, you can make the output function stop an optimizationwhen a user clicks a Stop buttonontheGUI.Thefollowingcodeshowshowto do this, assuming that the Stop button callback stores the value true inthe optimstop field of a handles structure called hObject:function stop = outfun(x)stop = false;% Check if user has requested to stop the optimization.stop = getappdata(hObject,'optimstop');Plot FunctionsThe PlotFcns field of the options structure specifies one or more functionsthat an optimization function calls at each iteration to plot various measuresof progress while the algorithm executes. The structure of a plot function isthe same as that for an output function. For more information on writing andcalling a plot function, see “Output Function” on page 6-16.To view and modify a predefined plot function listed for PlotFcns in theprevious table, you can open it in the MATLAB editor. For example, to viewthe M-file corresponding to the norm of residuals, type:edit optimplotresnorm.m6-25

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

Saved successfully!

Ooh no, something went wrong!