You cannot use the intergral function, as it does not exist. You could use integral, almost. :) Except that it does not apply to vectors of data. :(
The problem is, when you look at a sequence of values, for example
Is y a function? Yes, you may think of what you did as executing a function to obtain y. But if all we see is y, it is just a list of numbers. There is no connection between them. There is no knowledge that they represent values of something that WAS a function. MATLAB cannot know how the values in that list of numbers were obtained, or how to infer what should lie between the values, if you wanted it to do so.
So you have a simple solution. You can use trapz. You CANNOT use integral. Integral does not apply to vector of data.
Is that correct?
Sadly, no, because trapz is not exact for quadratic functions. And we know the origin of the vector y. It was pretty close though.
And a problem is, how could you integrate between two points that are not explicitly given in x?
One simple solution is to convert that list of points into a function, one that can then be integrated. So we might do this:
Now integral is exactly correct, to within floating point trash, at least. And now we can integrate between other limits.
Be careful about trying to go outside of the support of the spline though.
If you have the curve fitting toolbox, then you can use fnint to perform the integration.
In the end, you need to remember that vectors in MATLAB are just lists of numbers. You need to provide the intelligence in how to use them, what they mean to you, and what functions apply to them in context of their meaning to you.