Skip to Main Content Skip to Search
Product Documentation

quadv - Vectorized quadrature

Syntax

Q = quadv(fun,a,b)
Q = quadv(fun,a,b,tol)
Q = quadv(fun,a,b,tol,trace)
[Q,fcnt] = quadv(...)

Description

Q = quadv(fun,a,b) approximates the integral of the complex array-valued function fun from a to b to within an error of 1.e-6 using recursive adaptive Simpson quadrature. fun is a function handle. See Function Handles in the MATLAB Programming documentation for more information. The function Y = fun(x) should accept a scalar argument x and return an array result Y, whose components are the integrands evaluated at x. Limits a and b must be finite.

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

Q = quadv(fun,a,b,tol) uses the absolute error tolerance tol for all the integrals instead of the default, which is 1.e-6.

Q = quadv(fun,a,b,tol,trace) with non-zero trace shows the values of [fcnt a b-a Q(1)] during the recursion.

[Q,fcnt] = quadv(...) returns the number of function evaluations.

The list below contains information to help you determine which quadrature function in MATLAB to use:

Examples

For the parameterized array-valued function myarrayfun, defined by

function Y = myarrayfun(x,n)
Y = 1./((1:n)+x);

the following command integrates myarrayfun, for the parameter value n = 10 between a = 0 and b = 1:

Qv = quadv(@(x)myarrayfun(x,10),0,1);

The resulting array Qv has 10 elements estimating Q(k) = log((k+1)./(k)), for k = 1:10.

The entries in Qv are slightly different than if you compute the integrals using quad in a loop:

for k = 1:10
	Qs(k) = quadv(@(x)myscalarfun(x,k),0,1);
end

where myscalarfun is:

function y = myscalarfun(x,k)
y = 1./(k+x);

See Also

dblquad | function_handle | quad | quad2d | quadgk | quadl | triplequad

  


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