Lecture 18

Lecture 18 - MATLAB Function optimset The function optimset...

This preview shows pages 1–4. Sign up to view the full content.

The function optimset creates an options structure that you can pass as an input argument to the following four MATLAB optimization functions: fminbnd (single variable) local minimizer fminsearch (multi-variables) fzero lsqnonneg nonnegative least-squares constraints problem Example: options = optimset('Display','iter','TolFun',1e-8) This statement creates an optimization options structure in which the Display parameter is set to 'iter' and the TolFun parameter is set to 1e-8. MATLAB Function: optimset

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
>> options =optimset( 'display','iter' ); >> [x fx]=fzero(@(x) x^10-1,0.5, options ) Search for an interval around 0.5 containing a sign change: Func-count a f(a) b f(b) Procedure 1 0.5 -0.999023 0.5 -0.999023 init. intv 3 0.485858 -0.999267 0.514142 -0.998709 search 5 0.48 -0.999351 0.52 -0.998554 search 7 0.471716 -0.999454 0.528284 -0.998307 search 9 0.46 -0.999576 0.54 -0.997892 search 11 0.443431 -0.999706 0.556569 -0.997148 search 13 0.42 -0.999829 0.58 -0.995692 search 15 0.386863 -0.999925 0.613137 -0.992491 search 17 0.34 -0.999979 0.66 -0.984317 search 19 0.273726 -0.999998 0.726274 -0.959167 search 21 0.18 -1 0.82 -0.862552 search 23 0.0474517 -1 0.952548 -0.385007 search 25 -0.14 -1 1.14 2.70722 search fzero and optimset functions Find sign change after 25 iterations Switch to secant (linear) OR inverse quadratic interpolation to find root Search in both directions x 0 ± x for sign change
>> [x fx]=fzero(@(x) x^10-1,0.5, options ) Search for a zero in the interval [-0.14, 1.14]:

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern