15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

4 Function Functions<br />

States <strong>of</strong> the Algorithm<br />

The following table lists the possible values for state:<br />

State<br />

'init'<br />

'interrupt'<br />

'iter'<br />

'done'<br />

Description<br />

The algorithm is in the initial state before the first<br />

iteration.<br />

The algorithm is performing an iteration. In this state, the<br />

output function can interrupt the current iteration <strong>of</strong> the<br />

optimization. You might want the output function to do this<br />

to improve the efficiency <strong>of</strong> the computations. When state is<br />

set to 'interrupt', the values <strong>of</strong> x and optimValues are the<br />

same as at the last call to the output function, in which<br />

state is set to 'iter'.<br />

The algorithm is at the end <strong>of</strong> an iteration.<br />

The algorithm is in the final state after the last iteration.<br />

The following code illustrates how the output function might use the value <strong>of</strong><br />

state to decide which tasks to perform at the current iteration.<br />

switch state<br />

case 'init'<br />

% Setup for plots or guis<br />

case 'iter'<br />

% Make updates to plot or guis as needed.<br />

case 'interrupt'<br />

% Check conditions to see whether optimization<br />

% should quit.<br />

case 'done'<br />

% Cleanup <strong>of</strong> plots, guis, or final plot<br />

otherwise<br />

end<br />

Stop Flag<br />

The output argument stop is a flag that is true or false. The flag tells the<br />

optimization function whether the optimization should quit or continue. The<br />

following examples show typical ways to use the stop flag.<br />

4-20

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

Saved successfully!

Ooh no, something went wrong!