Skip to Main Content Skip to Search
Product Documentation

dblquad - Numerically evaluate double integral over rectangle

Syntax

q = dblquad(fun,xmin,xmax,ymin,ymax)
q = dblquad(fun,xmin,xmax,ymin,ymax,tol)
q = dblquad(fun,xmin,xmax,ymin,ymax,tol,method)

Description

q = dblquad(fun,xmin,xmax,ymin,ymax) calls the quad function to evaluate the double integral fun(x,y) over the rectangle xmin <= x <= xmax, ymin <= y <= ymax. fun is a function handle. See Function Handles in the MATLAB Programming documentation for more information. fun(x,y) must accept a vector x and a scalar y and return a vector of values of the integrand.

Parameterizing Functions, in the MATLAB Mathematics documentation, explains how to provide additional parameters to the function fun, if necessary.

q = dblquad(fun,xmin,xmax,ymin,ymax,tol) uses a tolerance tol instead of the default, which is 1.0e-6.

q = dblquad(fun,xmin,xmax,ymin,ymax,tol,method) uses the quadrature function specified as method, instead of the default quad. Valid values for method are @quadl or the function handle of a user-defined quadrature method that has the same calling sequence as quad and quadl.

Examples

Pass function handle @integrnd to dblquad:

Q = dblquad(@integrnd,pi,2*pi,0,pi);

where the function integrnd.m is:

function z = integrnd(x, y) 
z = y*sin(x)+x*cos(y);

Pass anonymous function handle F to dblquad:

F = @(x,y)y*sin(x)+x*cos(y);
Q = dblquad(F,pi,2*pi,0,pi);

The integrnd function integrates y*sin(x)+x*cos(y) over the square pi <= x <= 2*pi, 0 <= y <= pi. Note that the integrand can be evaluated with a vector x and a scalar y.

Nonsquare regions can be handled by setting the integrand to zero outside of the region. For example, the volume of a hemisphere is:

dblquad(@(x,y)sqrt(max(1-(x.^2+y.^2),0)), -1, 1, -1, 1)

or

dblquad(@(x,y)sqrt(1-(x.^2+y.^2)).*(x.^2+y.^2<=1), -1, 1, -1, 1)

See Also

function_handle | quad | quad2d | quadgk | quadl | triplequad

How To

  


Free MATLAB Interactive Kit

Explore how to use MATLAB to make advancements in engineering and science.


Download free kit

Trials Available

Try the latest version of MATLAB and other MathWorks products.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS