![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1423073/image.png)
I want to calculate the moving rms of accelerometer data.
조회 수: 113 (최근 30일)
이전 댓글 표시
Hi
I am working on a project where I get accelerometer data with a vector containing the acceleration (1019970 samples) and another vector containg the time corresponding to the acceleration vector. The sampling time is 1.6667e-04. I want to calculate the moving rms of this signal according to the signal. The formulas I have are for the integral notation and for the discrete time notation as seen below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1422928/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1422933/image.png)
How would I implement this in matlab to obtain the moving rms for the acceleration vector (without using simulink).
댓글 수: 0
채택된 답변
Star Strider
2023년 6월 30일
Try something like this —
Fs = 5000;
T = 100;
t = linspace(0, T*Fs, T*Fs-1)/Fs;
s = sin(2*pi*t*25);
xrms = @(s, n) sqrt(movmean(s.^2, n)); % Calculate RMS Function, 'n': Window Of Consecutive Data
figure
plot(t, s, 'DisplayName','Signal')
hold on
plot(t, xrms(s,100), 'DisplayName','RMS(Signal)')
hold off
grid
legend('Location', 'best')
xlim([0 1])
The ‘xrms’ function produces the expected result of
for the RMS value of a sine signal (after a short initial transient) over 100 data points (in this example).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1423073/image.png)
.
댓글 수: 7
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Signal Generation and Preprocessing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!