Here's an example code for a function that performs repeated Simpsons rule using a 2-column dataset in MATLAB:
main.m421 chars16 lines
You can call this function by passing a 2-column dataset to it, like this:
main.m76 chars3 lines
Note that the dataset data
should be arranged in a matrix with two columns, where the first column is the x values and the second column is the y values. Also note that this function only works for equally-spaced data points. If the data points are not equally-spaced, you need to use a different method to compute the integral.
gistlibby LogSnag