Matlab (latest, 2015) provides the integral function to numericaly compute integrals of functions
For functions that have a multi-dimensional domain (e.g matrix-valued functions) you can use the 'ArrayValued',true
option
Vector-Valued Function
Create the vector-valued function
f(x) = [sin x, sin 2x, sin 3x, sin 4x, sin 5x]
and integrate from x=0 to x=1
. Specify 'ArrayValued',true
to
evaluate the integral of an array-valued or vector-valued function.
fun = @(x)sin((1:5)*x);
q = integral(fun,0,1,'ArrayValued',true)
q =
0.4597 0.7081 0.6633 0.4134 0.1433
Alternatively, you can integrate the matrix-valued function element-wise, i.e per-element using loops, plus, one can also try to vectorize the operation to one without-loops (for example see here)
related question on scicomp.se