Operators > Calculus Operators > Example: Differentiation and Integration of Data Vectors
Example: Differentiation and Integration of Data Vectors
Use the cspline function for performing differentiation and integration on an x-y data set.
Derivative Fitting Function
Interpolate a curve from a data set and find the gradient of the curve.
1. Define the following matrix.
2. Make sure that the x values are in ascending order in the first column of the data matrix before extracting vectors of x and y values.
3. Call the cspline function to find the cubic spline coefficients for interpolation.
4. Call the interp function to interpolate a curve through the data points. Plot the data points and the interpolated curve.
5. Differentiate function F.
6. Calculate an approximation of the gradient for each data point.
This secant approximation to the derivative is a crude but valid comparison for the differentiated curve.
7. Plot the differentiated curve and the approximations of the gradient.
Integral Fitting Function
1. Integrate the function F.
2. Calculate an approximation of the integral for each data point.
3. Plot the integrated curve and the approximations of the integral.