1

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?

1
  • 3
    Doesn't this boil down to computing 1/2 * att + b*t for all elements t of your vector? Commented Apr 4, 2012 at 20:49

2 Answers 2

3

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
Sign up to request clarification or add additional context in comments.

Comments

0

cumtrapz();

seriously CumTrapz

It computes the trapazoidal aproximation of the integral.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.