Hi MatG,
As with a lot of things, the answer depends. In your example, which is the first case below, the variation in power is not very extreme, which means that the two methods will not differ by very much. On the other hand, the second case is for a square wave that spends half its time around the value 1, and the other half of the time around the value 0, plus a bit of noise. Here the difference between the two methods is very large.
t = 0:.001:2*pi;
n = length(t);
r = 2*rand(1,n)-1;
P = 10.^((5/10)*r);
figure(1)
plot(t,P)
grid on
mean_of_P_in_dB = 10*log10(mean(P))
mean_of_dB = mean(10*log10(P))
y = (1+square(t))/2;
P = (y +.001*r).^2;
figure(2)
plot(t,P)
grid on
mean_of_P_in_dB = 10*log10(mean(P))
mean_of_dB = mean(10*log10(P))
In the second case, the average power is about 1/2, so the mean of P converted to dB is -3 dB. That is a reasonable evaluation of the situation. When direct averaging dB, the signal spends half its time at 0 dB and half down in the region of -60 dB, leading to the somewhat absurd conclusion that the average power is -34 dB. Make the noise 10 times smaller than that, and the supposed average power is now -44 dB. This is not reasonable. Most cases are like your example, though, and averaging dB can make sense.
1 Comment
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/706078-means-squared-error-and-db#comment_1237728
Direct link to this comment
https://de.mathworks.com/matlabcentral/answers/706078-means-squared-error-and-db#comment_1237728
Sign in to comment.