Here is the code for Simpson's Rule using recursion in MATLAB:
main.m1052 chars38 linesTo use this code, define your function f(x) as a separate MATLAB function or as an anonymous function, then call SimpsonsRule(f,a,b,n) with the appropriate values for a,b,n. Note that n must be an even integer for Simpson's Rule to be applied, and that this code uses recursion to divide the interval into smaller subintervals until convergence is achieved.
gistlibby LogSnag