I have to plot the RMS graph over time of the signal related to the left anterior tibial muscle, I calculated the value with the matlab 'rms' command but I only get a value and not a vector to plot. I need the matlab code.

 채택된 답변

Star Strider
Star Strider 2021년 3월 25일

1 개 추천

The RMS value needs to be calculated for a vector. Since the RMS =s the square root of the mean of the squared values of that vector, one option is to use the movmean function to create a moving estimate of the RMS value.
Try this:
t = linspace(0, 10, 1000); % Time Vector
v = 1.2+sin(2*pi*t*100)+randn(1,1000)*0.1; % EMG Vector
WinLen = 10; % Window Length For RMS Calculation
rmsv = sqrt(movmean(v.^2, 10)); % RMS Value Over ‘WinLen’ Samples
figure
plot(t, v)
hold on
plot(t, rmsv, '-r', 'LineWidth',1.5)
hold off
grid
legend('EMG',sprintf('RMS (Window Length = %d)',WinLen), 'Location','best')
Experiment to get the result you want.

댓글 수: 6

barbara falconi
barbara falconi 2021년 3월 26일
If I filter the rectified signal with a low pass filter at a cutoff frequency of 15 Hz, do I get the same thing?
Star Strider
Star Strider 2021년 3월 26일
Not necessarily.
The rectified signal (and it depends on whether this is full-wave or half-wave rectification) will simply give you the absolute value of the signal (or the positive half, for half-wave rectification). If the output of the filter is a relatively constant value, that would likely approximate the RMS value of the signal. However if it still contains ‘significant’ periodic components, it would not necessarily be the same as the RMS value, although it would likely be close to it.
I would have to know more about the rectification, the signal, and the filter.
barbara falconi
barbara falconi 2021년 3월 26일
If I use the command rms (signal, dim) I get a vector equal to the vector of the full wave rectified signal and it seems strange to me. Why is the window 10 long?
Star Strider
Star Strider 2021년 3월 26일
For a vector, the rms function result should be a scalar. For a matrix, it should be scalars for every column, unless the dim argument specifies a different dimension. See the Description section of the rms documentation for details.
The code I provided will return the RMS value of ‘WinLen’ samples of the vector over the entire vector. That value should be at least 2 (taking the RMS value of a single value is meaningless), and less than the length of the entire vector. The number of samples you choose in the calculation is your choice.
barbara falconi
barbara falconi 2021년 3월 26일
ok,thank you
Star Strider
Star Strider 2021년 3월 26일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

태그

질문:

2021년 3월 25일

편집:

2021년 3월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by