Is it possible to perform double integration where the inner variable limits are a function of the value of the outer variable?

4 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 10 Sep 2012
The best available method is using the INT function from the Symbolic Math Toolbox. For more information on this function, type 'help int' at the MATLAB Command Prompt. If you have installed the documentation, type 'doc int' to see the documentation for this function. If you do not have the documentation installed, you can find it here:
<http://www.mathworks.com/help/toolbox/symbolic/int.html>
An example of how to use INT to integrate f(x,y)=x*y from x=0 to x=y and y=0 to y=1 is:
syms x y
integrand = @(x,y) x*y
int(int(integrand(x,y),0,y),0,1)
Another workaround is to construct the function to be integrated with an appropriate region of interest. An example performing the same integration as the example above is:
F = @(x,y) (x<y).*(x*y)
dblquad(F,0, 1, 0, 1)
patch([0 1 1],[0 0 1],[1 0 0])
The red area in the figure describes the region over which the function x*y will be integrated by the code above. Outside this region, the function F will be zero and will therefore not contribute to the integral.
If you are using a version of MATLAB older than MATLAB 7.0 (R14), you will need to use a function file or an inline function to define the integrand. To perform this integration using an inline function, try:
F = inline('(x<y).*(x*y)', 'x','y')
dblquad(F,0, 1, 0, 1)
Or, create a function “myF.m” containing:
function F = myF(x,y)
F = (x<y).*(x*y);
Then, call DBLQUAD in the MATLAB workspace:
dblquad(@myF,0,1,0,1)

More Answers (0)

Categories

Find more on Function Creation in Help Center and File Exchange

Products


Release

No release entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!