Clear Filters
Clear Filters

envelope rms implementation review

19 views (last 30 days)
Gideon Kogan
Gideon Kogan on 24 Sep 2020
Edited: Chunru on 8 Nov 2021
I am trying to implement the moving RMS by Matlab.
x = randn(50, 1);
xRMS = sqrt(movmean(x.^2, 21));
xRMSref = envelope(x, 21, 'rms');
plot(xRMSref,'DisplayName','xRMSref');hold on;plot(xRMS,'DisplayName','xRMS');hold off;
legend()
Why my estimation differs from Matlab's? What actually implemented by Matlab? The algorithm description is not delailed and movrms function is locked...
  1 Comment
Nim Pim
Nim Pim on 8 Nov 2021
Hi. I too found that moving RMS function of dsp tool box not giving the correct values. I tried it on a small data set and the manually calculated values were different. So confusing....

Sign in to comment.

Answers (1)

Chunru
Chunru on 8 Nov 2021
Edited: Chunru on 8 Nov 2021
"envelope" removes the mean first before doing movrms and it restore the mean offset in the end.
If you nake sure the signal is 0-mean, then the results would be quite same.
x = randn(50, 1);
x = x -mean(x);
xRMS = sqrt(movmean(x.^2, 21));
xRMSref = envelope(x, 21, 'rms');
plot(xRMSref,'DisplayName','xRMSref');
hold on;
plot(xRMS,'DisplayName','xRMS');hold off;
legend()

Products

Community Treasure Hunt

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

Start Hunting!