28.12.2012 Views

Figure Properties - SERC

Figure Properties - SERC

Figure Properties - SERC

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

fminbnd<br />

2-860<br />

The argument fun can also be a function handle for an anonymous function.<br />

For example, to find the minimum of the function fx ( ) x on the<br />

interval (0,2), create an anonymous function f<br />

3 =<br />

– 2x – 5<br />

f = @(x)x.^3-2*x-5;<br />

Then invoke fminbnd with<br />

x = fminbnd(f, 0, 2)<br />

The result is<br />

x =<br />

0.8165<br />

The value of the function at the minimum is<br />

y = f(x)<br />

y =<br />

-6.0887<br />

If fun is parameterized, you can use anonymous functions to capture the<br />

problem-dependent parameters. For example, suppose you want to minimize<br />

the objective function myfun defined by the following M-file function.<br />

function f = myfun(x,a)<br />

f = (x - a)^2;<br />

Note that myfun has an extra parameter a, so you cannot pass it directly to<br />

fminbind. To optimize for a specific value of a, such as a = 1.5.<br />

1 Assign the value to a.<br />

a = 1.5; % define parameter first<br />

2 Call fminbnd with a one-argument anonymous function that captures that<br />

value of a and calls myfun with two arguments:<br />

x = fminbnd(@(x) myfun(x,a),0,1)<br />

Algorithm The algorithm is based on golden section search and parabolic interpolation. A<br />

Fortran program implementing the same algorithm is given in [1].

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

Saved successfully!

Ooh no, something went wrong!