No BSD License  

Highlights from
A double integration of the tabulated data.

1.0

1.0 | 1 rating Rate this file 5 Downloads (last 30 days) File Size: 706 Bytes File ID: #13644

A double integration of the tabulated data.

by Robertas balevicius

 

12 Jan 2007 (Updated 12 Jan 2007)

A double integration of the tabulated data.

| Watch this File

File Information
Description

A double integration of the tabulated data. f(x,y) may be generated in terms of meshgrid. Double integral computes simply by approximation of the integral for f(x,y) via the trapezoidal method.
Firstly, an integration loop within inner integral over X is performed obtaining the function of area A(y). Secondly, outer loop integration is performed for A(y) over y limits
 Example:
 Q = dblquad(inline('y*sin(x)+x*cos(y)'), pi, 2*pi, 0, pi);
 Q = -9.8696
 [X,Y] = meshgrid(pi:pi/100:2*pi, 0:pi/100:pi );
 Z=Y.*sin(X)+X.*cos(Y);
 int_2D_tabulated(X,Y, Z )
 ans = -9.8688

MATLAB release MATLAB 6.5 (R13)
Other requirements ---
Tags for This File  
Everyone's Tags
computes, data, double, integration, mesh grid, tabulated
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
16 Jan 2007 dave martin

If you want to see this code without downloading it, here you go:

function V = int_2D_tabulated(X, Y, Z )
V = trapz( Y(:,1), (trapz(X(1,:),Z, 2)) );

16 Jan 2007 dave martin

Sorry, there is no need for the return statement. This is essentially a one liner with a name that is harder to remember than 'trapz' in the first place. This is cumbersome!

12 Jan 2007 John D'Errico

But I can call trapz twice with no more effort. Why bother with a special function for something this trivial, since all it does is call trapz twice anyway?

Contact us