Integration the product of two data sets

4 views (last 30 days)
Ram Kumar PK
Ram Kumar PK on 28 Mar 2014
Answered: Roger Stafford on 28 Mar 2014
I have two data sets, acceleration vs velocity v and an another function P(v) vs v. Now I have to integrate the product of these two i.e acc * P(v) wrt to v. My problem is the size and elements of velocity v in both these data sets(they are in form of four different arrays) is not same, i.e the array v in the first set(with acceleration) goes 15,20,25,...kph while the other v array goes 15,16,17...etc. So how to use trapz here? Or would it be better for me to get two analytical curves, acc vs v and P vs v, using curve fitting and then integrate their product?

Answers (1)

Roger Stafford
Roger Stafford on 28 Mar 2014
You cannot use 'trapz' on the two sets of data as they stand. To get an accurate integral of the product, the two factors must correspond to the same values of v. I would suggest you interpolate one of the sets of data, presumably the one with the coarser intervals, onto the closer-spaced values of v of the other factor, and then use 'trapz' on that common set of v values for the product.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!