15.11.2014 Views

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

MATLAB Mathematics - SERC - Index of

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.

Numerical Integration (Quadrature)<br />

To perform the integration, two functions are available in the funfun directory.<br />

The first, dblquad, is called directly from the command line. This M-file<br />

evaluates the outer loop using quad. At each iteration, quad calls the second<br />

helper function that evaluates the inner loop.<br />

To evaluate the double integral, use<br />

result = dblquad(@integrnd,xmin,xmax,ymin,ymax);<br />

The first argument is a string with the name <strong>of</strong> the integrand function. The<br />

second to fifth arguments are<br />

xmin<br />

xmax<br />

ymin<br />

ymax<br />

Lower limit <strong>of</strong> inner integral<br />

Upper limit <strong>of</strong> the inner integral<br />

Lower limit <strong>of</strong> outer integral<br />

Upper limit <strong>of</strong> the outer integral<br />

Here is a numeric example that illustrates the use <strong>of</strong> dblquad.<br />

xmin = pi;<br />

xmax = 2*pi;<br />

ymin = 0;<br />

ymax = pi;<br />

result = dblquad(@integrnd,xmin,xmax,ymin,ymax)<br />

The result is -9.8698.<br />

By default, dblquad calls quad. To integrate the previous example using quadl<br />

(with the default values for the tolerance argument), use<br />

result = dblquad(@integrnd,xmin,xmax,ymin,ymax,[],@quadl);<br />

Alternatively, you can pass any user-defined quadrature function name to<br />

dblquad as long as the quadrature function has the same calling and return<br />

arguments as quad.<br />

4-29

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

Saved successfully!

Ooh no, something went wrong!