Needed RMS for matlab code for a ECG signal

18 views (last 30 days)
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.

Accepted Answer

Geetla Sindhu
Geetla Sindhu on 9 Nov 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.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!