Thanks.

But seriously, I am a matlab noob. Reading the matlab documentation is like looking up a tamil dictionary. Searching for the definition of one tamil word only returns even more tamil words.. all gibberish to me. I'm sorry for being bothersome.

Now this is the documentation I got from downloading the intgrad1 file. I have no idea what it is talking about.

But at the end there is an example

Code:

% Example usage:
% x = 0:.001:1;
% f = exp(x) + exp(-x);
% dfdx = exp(x) - exp(-x);
% tic,fhat = intgrad1(dfdx,.001,2,2);toc

here it shows that f(x) = known = exp(x) + exp(-x)

Is there a way to specify f(x) in terms for the data points?

If plot() can do it I don't see why there isn't a way to do something like

Code:

% psuedo code
f = plot(x, y);
A = integrate(f);

This has to be a common task! Would appreciate if can get further help. Thanks in advance!

Code:

% intgrad: generates a vector, integrating derivative information.
% usage: fhat = intgrad1(dfdx)
% usage: fhat = intgrad1(dfdx,dx)
% usage: fhat = intgrad1(dfdx,dx,f1)
% usage: fhat = intgrad1(dfdx,dx,f1,method)
%
% arguments: (input)
% dfdx - vector of length nx, as gradient would have produced.
%
% dx - (OPTIONAL) scalar or vector - denotes the spacing in x
% if dx is a scalar, then spacing in x (the column index
% of fx and fy) will be assumed to be constant = dx.
% if dx is a vector, it denotes the actual coordinates
% of the points in x (i.e., the column dimension of fx
% and fy.) length(dx) == nx
%
% DEFAULT: dx = 1
%
% f1 - (OPTIONAL) scalar - defines the first eleemnt of fhat
% after integration. This is just the constant of integration.
%
% DEFAULT: f1 = 0
%
% method - (OPTIONAL) scalar - either 0, 1, 2, or 3. Defines
% the integration scheme used.
%
% method = 0 --> cumtrapz
%
% method = 1 --> solves central finite difference
% approximation using linear algebra
% A second order fda. At least 3 points
% are necessary.
%
% method = 2 --> integrated spline model
% This will almost always be the most
% accurate among the alternative methods.
%
% method = 3 --> integrated pchip model
%
% method = 4 --> higher order finite difference approximation
% A 4th order fda. At least 5 points are
% necessary.
%
% DEFAULT: method = 2
%
% Note: method = 0 (cumtrapz) will generally be the fastest,
% and method = 2 (spline integral) will be the most accurate
% of the four methods.
% Methods 1, 3, and 4 were put in there mainly for fun on my
% part, lthough for equally spaced points, the 4th order fda
% should also be quite accurate.
%
% Data series with noise in them may be best integrated using
% a lower order method to avoid noise amplification.
%
% arguments: (output)
% fhat - vector of length nx, containing the integrated function
%
% Example usage:
% x = 0:.001:1;
% f = exp(x) + exp(-x);
% dfdx = exp(x) - exp(-x);
% tic,fhat = intgrad1(dfdx,.001,2,2);toc