MATLAB Filter out constant of integration?

AI Thread Summary
The discussion revolves around integrating a signal from an oscilloscope and the challenges of removing the constant of integration. The user expresses concern that the cumtrapz function is not yielding correct results due to non-ideal sine wave signals. Suggestions include using the Fourier transform for clean signals and subtracting the mean value to achieve oscillation around zero. It is noted that a sum or definite integral does not include a constant of integration, and removing the last term in the sum would be incorrect. The user plans to experiment with subtracting the average value from the signal to address the issue.
Helmholtzerton
Messages
30
Reaction score
4
Hello,

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?
 
Physics news on Phys.org
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.
 
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.
 
mfb said:
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.

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.

example.png


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
 
You can simply calculate the average y value and subtract that from your signal.
 

Similar threads

Replies
3
Views
5K
Replies
1
Views
8K
Replies
1
Views
2K
Replies
3
Views
1K
Replies
13
Views
12K
Replies
1
Views
11K
Back
Top