Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB Filter out constant of integration?

  1. Mar 22, 2017 #1

    I'm trying to integrate a signal received on an oscilliscope, but I'm afraid using the function cumtrapz is not giving me the correct value. Here is what I'm seeing when testing out sine functions cumtrapzQ.png

    I could apply an FFt to obtain the components and the phases, and then subtract off the constant of integration. However my signals are not clean sineusoids.

    Are there any integration techniques I can apply which can subtract off this constant?
  2. jcsd
  3. Mar 22, 2017 #2


    User Avatar
    2017 Award

    Staff: Mentor

    Summing from i=1 to i doesn't make sense.
    A sum or a definite integral won't have a constant of integration. The shown sum is correct (with some interpretation how to resolve the "i" issue), and as you can see the partial sums start at zero - as they should. Removing the last term would make the expression wrong.
  4. Mar 22, 2017 #3


    Staff: Mentor

    The integral looks correct to me.

    You can, of course, add an arbitrary constant to get another function with the same derivative. For example you can take the mean and subtract that, etc.
  5. Mar 23, 2017 #4
    Sorry, what I was trying to convey is for all sin functions that comprise of f(x). That is....

    Say you have the following f(x) = sin(t) + 3sin(2t+pi/4)

    Then the constant of integration to subtract off would be = cos(0)+ 3/2cos(pi/4) = 1+1.0607 = 2.0607

    the anti derivative of f(x) = -cos(t) - 3/2*cos(2t+pi/4) + C

    I want to subtract off C so that I oscillate about 0.

    Below, in the bottom graph, shows this. Where the oscillation is between 2 and -2, where as the top graph is offset.


    This is fairly easy to do with clean signals by just taking the Fourier transform, and applying my formula for the extracted amplitudes, frequency, and phase shift. But signal data from an oscilloscope is not that clean, and so my method won't work for this. The offset that comes from the numerical integration doesn't make physical sense.

    I'll try to experiment with taking the mean and subtracting it off to see if the numerical integration of sin(t) can simply give me -cos(t) over all of t instead of -cos(t)+C
  6. Mar 23, 2017 #5


    User Avatar

    Staff: Mentor

    You can simply calculate the average y value and subtract that from your signal.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted