Z = SIMPS(Y) computes an approximation of the integral of Y via the Simpson's method (with unit spacing). To compute the integral for spacing different from one, multiply Z by the spacing increment.
Z = SIMPS(X,Y) computes the integral of Y with respect to X using the Simpson's rule.
Z = CUMSIMPS(Y) computes an approximation of the cumulative integral of Y via the Simpson's method (with unit spacing).
Z = CUMSIMPS(X,Y) computes the cumulative integral of Y with respect to X using Simpson's integration.
SIMPS and CUMSIMPS use the same syntaxes as TRAPZ and CUMTRAPZ, respectively
Enter "help simps" and "help cumsimps" in the Matlab command window for complete information.
Examples:
--------
% The integral of sin(x) on [0,pi] is 2
% Let us compare TRAPZ and SIMPS
x = linspace(0,pi,6);
y = sin(x);
trapz(x,y) % returns 1.9338
simps(x,y) % returns 2.0071
% The integral of cos(x) is sin(x)
% Let us compare CUMTRAPZ and CUMSIMPS
x = linspace(0,2*pi,20);
y = cos(x);
yt = cumtrapz(x,y);
ys = cumsimps(x,y);
% RMSE: root mean squared errors:
sqrt(mean((yt-sin(x)).^2)) % returns 0.0063
sqrt(mean((ys-sin(x)).^2)) % returns 1.2309e-004
------
Other examples are given in:
http://www.biomecardio.com/matlab/simps.html
http://www.biomecardio.com/matlab/cumsimps.html
-----
|