# Sine wave integration doubt?

58 views (last 30 days)
GD on 6 Jun 2016
Answered: Simeon Kruger on 23 Feb 2021
I am integrating a sine wave having amplitude one, but the output that I get from intergrator is -cos (expected), but with some offset and also the amplitude is attenuated. Why is it so?

Simeon Kruger on 23 Feb 2021
I realize that this is an old question, but I would like to elaborate on the answer John D'Errico gave, in case somebody else comes across a similar problem:
If you are working with power systems and a sinusoidal voltage source with a given frequency, then you should also bear in mind that the integrated signal will show considerable attenuation. This will be evident in the Simulink Integrator block, the trapz command and the cumtrapz command.
Let us suppose that you have a voltage source with a frequency of 50 Hz and that the amplitude of your waveform is 1 - then the voltage waveform is given by . One might then be tempted to assume that since , the integrated waveform should also have an amplitude of 1.
But and this will result in a considerable attenuation of the integrated signal, which is not caused by the numerical approximations of trapz and cumtrapz.

John D'Errico on 6 Jun 2016
Edited: John D'Errico on 6 Jun 2016
How are you doing the integration? What EXACTLY did you do?
For example, if you used cumtrapz to integrate a sine wave, it will under-estimate the integral. As well, remember that there is that constant of integration in there, something that cumtrapz knows nothing of.
So the integral of sin(t) is -cos(t)+c, where c is a constant of integration.
t = linspace(0,2*pi,11);
x = sin(t);
xint = cumtrapz(t,x);
plot(t,xint)
grid on
So, we see an offset cosine wave, with an amplitude a bit low, because trapezoidal rule will always produce a biased estimate for a sine wave (biased towards zero). So the amplitude looks wrong.
Or, does your function have some noise in it? Again, you cannot expect an exact result.

### Categories

Find more on Numerical Integration and Differentiation in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by