How can I integrate a set of data that has been fit with a cubic spline interpolation?

33 views (last 30 days)
I have a few sets of data and I am trying to apply a fitted curve to, which would then allow me to integrate the functions. I have learned how to do this with nearly all the fits (such as polynomial, Fourier, Gauss, etc.). However I've recently found out about the cubic spline interpolation, which produces a piece wise function. However I am running into issues as I do not have any idea how to integrate this. I've been trying for the past few hours to figure this out and I cant seem to make any progress:
Here is a sample of the code I'm working on:
A = csvread('C:\Users\Chris\Desktop\SORA Science\Test Files\Grating #H1.csv');
x = A(:,1);
xf = x(end);
y = A(:,2);
yf = y(end);
xx = 0:xf
pp = spline(x,y,xx);
plot(x,y,'.',xx,pp);
axis([0,xf,0,100]);
This code successfully plots my data and applies the cubic spline interpolation for a particular file.
How might I be able to integrate the function that is produced?

Answers (1)

Walter Roberson
Walter Roberson on 13 Apr 2016

Community Treasure Hunt

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

Start Hunting!