t = 0:0.001:1;
y1 = 400 * sin(2*pi*20*t);
y2 = 200 + 400 * sin(2*pi*20*t);
hold on
grid on;
rms_y1 = sqrt(mean(y1.^2)) 
rms_y2 = sqrt(mean(y2.^2)) 

In the above MATLAB code there are two signals y1 and y2.

y1 is a sinusoidal signal 20 Hz with 400V amplitude.

y2 is a signal which is nothing but y1 + 200V DC offset.

So I was thinking the "rms of y2" would be equal to "rms of y1 + 200". Since rms of a constant is the constant itself.

But rms of y1 is 282.7014; and rms of y2 turns out to be 346.2948 (not 282 + 200).

What am I doing wrong here?

  • $\begingroup$ you are possibly confusing RMS with variance. These two signals do have the same variance, but their RMS also depends on their DC points. Hence the computation is right according to $X_{RMS} = \sqrt { \frac{1}{T} { \int_{0}^{T}{x^2(t) dt} } }$ $\endgroup$ – Fat32 Jun 8 '16 at 13:35

RMS values don't simply add up. The RMS value of $N$ discrete samples $x[n]$ (assuming $0\le n<N$) is


Now if you have $y[n]=x[n]+c$ with some constant $c$, the RMS value of $y[n]$ is


If we define the mean value of $x[n]$ as


then from $(2)$ the square of the RMS value of $y[n]$ can be expressed as


So if you assume that the mean of $x[n]$ equals zero, the squares of the RMS values add up:


You can easily verify Eq. $(5)$ using your example:


  • $\begingroup$ so the eq. sqrt(mean(y.^2)) is correct ? thanks $\endgroup$ – user16307 Jun 8 '16 at 14:07
  • $\begingroup$ @user16307: Yes, it is (for real-valued vectors), but there's actually also the Matlab command 'rms'. $\endgroup$ – Matt L. Jun 8 '16 at 14:13
  • $\begingroup$ mine is Matlab 6 it doesnt have that function $\endgroup$ – user16307 Jun 8 '16 at 14:15

Your intuition is wrong.

If your y2 was more like:

y2 = 200*sign(sin(2*pi*20*t)) + 400 * sin(2*pi*20*t);

then your intuition would be correct.

The issue is that adding a constant value to the sinusoid adds to the sinusoid's RMS value when the sinusoid is positive (and the offset is positive) but subtracts from the RMS value when the sinusoid is negative.

Making the DC offset increase the RMS value in both polarities will get you what you expect.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.