Cumulative RMS in Matlab

14 visualizaciones (últimos 30 días)
Frederick Wells
Frederick Wells el 4 de Mzo. de 2021
Editada: Frederick Wells el 8 de Mzo. de 2021
Hi,
I'm trying to find the cumulative RMS of a vector. (The data happens to be model error - labelled devCoM for deviation of centre of mass. The calculation should get less accurate as time proceeds, so cumulative error is important.)
I can find the cumulative sum by taking
cumsum(devCoM)
...but this fluctuates about zero.
I can find the RMS of the entire dataset by taking
sqrt(sum(devCoM.^2)
...but this doesn't reveal the expected increase in error over time.
Is there some way I could combine these methods?
Thanks,
Frederick

Respuesta aceptada

Jan
Jan el 4 de Mzo. de 2021
Editada: Jan el 4 de Mzo. de 2021
Start with a mathematical definition of what you want to achieve.
I guess you want this:
x = rand(1, 100); % Your data
% "Cumulative root mean square"
y = sqrt(cumsum(x.*x) ./ (1:numel(x)))
So the cumulative concerns the mean of the squared elements only, correct?
  1 comentario
Frederick Wells
Frederick Wells el 8 de Mzo. de 2021
Editada: Frederick Wells el 8 de Mzo. de 2021
Great, this does just want I wanted it to! Thanks very much :)
Had some trouble for a while since I was using a column vector and the denominator produces a row, so the code that ultimately worked for me was
y = sqrt(cumsum(x.^2) ./ (1:numel(x))');

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Elementary Math en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by