Search code examples
matlabintegral

Efficient integral function in Matlab


I have a function of the form a*x + b and I want to integrate this function from 0 to t where t will be set to the values of a very large (length 100000) vector repeatedly. I used quad function in a for loop, but it takes too much time to compute the integral for each value in the vector. Is there any efficient way to implement this in Matlab?


Solution

  • Actually, you dont need to implement it yourself, you may search it by using "matlab numerical integration functions"...

    First functons comes into my mind are;

    Trapezoidal --> trapz(X,Y)
    
    Cumulative Trapezoidal --> cumtrapz(X,Y)
    
    Adaptive Lobatto Quadrature --> quadl
    
    Adaptive Gauss-Kronrod Quadrature --> quadgk
    
    Vectorized Quadrature --> quadv