Needed RMS for matlab code for a ECG signal

25 visualizaciones (últimos 30 días)
Sachini Perera
Sachini Perera el 6 de Nov. de 2022
Respondida: Geetla Sindhu el 9 de Nov. de 2022
I tried using the matlab RMS for this but it does not work as it is not very detailed. If possile can you supply a code that would help to calculate the RMS function. I did try using https://au.mathworks.com/matlabcentral/fileexchange/11871-signal-rms?s_tid=FX_rc1_behav function but i dont understand what overlap and zeropad values are.

Respuesta aceptada

Geetla Sindhu
Geetla Sindhu el 9 de Nov. de 2022
Hello Sachini,
I understand that you are trying to estimate the RMS values of a signal for every 1 second interval.
Since the RMS is 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.
You can try this example:
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, WinLen)); % RMS Value Over ‘WinLen’ Samples
This code will give the RMS value of ‘WinLen’ samples of the vector over the entire vector. The number of samples can be chosen depending on the 1 second interval (i.e., No. of samples in 1 sec interval).
OR
The function
y = rms(signal, windowlength, overlap, zeropad)
can also be used.
Where, signal is a 1-D vector
windowlengthis an integer length of the RMS window in samples
overlap is the number of samples you want to overlap with the adjacent windows (0 for non-overlapping windows).
zeropad is a flag for zero-padding the end of the data
(If the total number of samples = 45 and windowlength = 10, then in the last window there are only 5 samples available. So, in order to make it to 10 samples we add zeros at the end of the data which is known as zero padding).
Thank you.

Más respuestas (0)

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by