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.

fminsearch8.1777e-010This indicates that the minimizer was found to at least four decimalplaces with a value near zero.Example 2If fun is parameterized, you can use anonymous functions to capturethe problem-dependent parameters. For example, suppose you want tominimize the objective function myfun defined by the following M-filefunction.function f = myfun(x,a)f = x(1)^2 + a*x(2)^2;Note that myfun has an extra parameter a, soyoucannotpassitdirectlyto fminsearch. Tooptimizeforaspecificvalueofa, suchasa = 1.5.1 Assign the value to a.a = 1.5; % define parameter first2 Call fminsearch with a one-argument anonymous function thatcaptures that value of a and calls myfun with two arguments:x = fminsearch(@(x) myfun(x,a),0,1)Example 3You can modify the first example by adding a parameter a to the secondterm of the banana function:This changes the location of the minimum to the point [a,a^2]. Tominimize this function for a specific value of a, forexamplea=sqrt(2),create a one-argument anonymous function that captures the value of a.8-72

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

Saved successfully!

Ooh no, something went wrong!