1
$\begingroup$
t = 0:0.001:1;
y1 = 400 * sin(2*pi*20*t);
y2 = 200 + 400 * sin(2*pi*20*t);
plot(t,y1)
hold on
plot(t,y2,'-g')
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?

$\endgroup$
  • $\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
3
$\begingroup$

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

$$x_{RMS}=\sqrt{\frac{1}{N}\sum_{n=0}^{N-1}x^2[n]}\tag{1}$$

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

$$\begin{align}y_{RMS}&=\sqrt{\frac{1}{N}\sum_{n=0}^{N-1}y^2[n]}\\&=\sqrt{\frac{1}{N}\sum_{n=0}^{N-1}(x[n]+c)^2}\\&=\sqrt{\frac{1}{N}\sum_{n=0}^{N-1}(x^2[n]+2cx[n]+c^2)}\\&=\sqrt{\frac{1}{N}\sum_{n=0}^{N-1}x^2[n]+\frac{2c}{N}\sum_{n=0}^{N-1}x[n]+\frac{1}{N}\sum_{n=0}^{N-1}c^2}\tag{2}\end{align}$$

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

$$m_x=\frac{1}{N}\sum_{n=0}^{N-1}x[n]\tag{3}$$

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

$$y^2_{RMS}=x^2_{RMS}+2cm_x+c^2\tag{4}$$

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

$$y^2_{RMS}=x^2_{RMS}+c^2\tag{5}$$

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

$$(282.7014)^2+(200)^2=(346.2948)^2\tag{6}$$

$\endgroup$
  • $\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
0
$\begingroup$

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.

$\endgroup$

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.