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.
Click to copy this expression
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.
Click to copy this expression
Click to copy this expression
Click to copy this expression
3. Call the cspline function to find the cubic spline coefficients for interpolation.
Click to copy this expression
4. Call the interp function to interpolate a curve through the data points. Plot the data points and the interpolated curve.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
5. Differentiate function F.
Click to copy this expression
6. Calculate an approximation of the gradient for each data point.
Click to copy this expression
Click to copy this expression
Click to copy this expression
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.
Click to copy this expression
Integral Fitting Function
1. Integrate the function F.
Click to copy this expression
2. Calculate an approximation of the integral for each data point.
Click to copy this expression
Click to copy this expression
Click to copy this expression
Click to copy this expression
3. Plot the integrated curve and the approximations of the integral.
Click to copy this expression