Fast Trapezoidal Integration

Similar to TRAPZ but (up to) 16x-times faster. Equally spaced data NOT required.
3.5K Downloads
Updated Fri, 13 Oct 2006 11:00:40 +0000

No License

F=trapzf(X,Y) computes the integral of Y with respect to X using the trapezoidal method. X and Y must be vectors of the same length.
For trapzf to work properly:
X must be a STRICTLY monotonically increasing vector.

Example:
>> x=[1:1:1000];
>> y=log(sqrt(x+1.001)-1.001);
>> area=trapzf(x,y);

Warning: not much in the way of error checking, since this slows things down, so pay attention to the argument passed to the function!!!

Installation (Windows users):
------------------------------

Simply copy the trapzf.dll file in a directory recognizable by MATLAB. You won't need trapzf.c to perform computations, but it is useful if you want to read the user instructions or to customize your code.
If you modify trapzf.c then you must run the following command

mex trapzf.c

in order to obtain the new dll file.

Installation (other OS users):
-------------------------------

A precompiled c-mex file is not provided.
You have to compile trapzf.c with your favourite C compiler (write "mex -setup" at the MATLAB prompt), then write

mex trapzf.c

in order to obtain the corresponding mex-file (see the table below)

OS ---> Extension
------------------------------
sol2, SunOS 5.x ---> .mexsol
hpux ---> .mexhpux
hp700 ---> .mexhp7
ibm_rs ---> .mexrs6
sgi ---> .mexsg
alpha ---> .mexaxp
glnx86 ---> .mexglx

PLEASE RATE MY SUBMISSION!

Cite As

Umberto Picchini (2024). Fast Trapezoidal Integration (https://www.mathworks.com/matlabcentral/fileexchange/8644-fast-trapezoidal-integration), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Interpolation in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0.0

old dll file substitute with a dll created using the LCC compiler