rms function seems to be missing. How do I write my own m file to do the same thing?

I need to take the rms value of each row of a matrix. Some googling lead me to the rms function, which uses the syntax: Y = rms(X,DIM). So in my case I believe that Y=rms(X,2) is exactly what I need. However, the rms function is not present in my version of matlab (is it part of the statistical toolbox or something?)
So, how would I write my own function to do this? I understand what rms is and how to calculate it, but it's mostly the issue of telling it to compute rms for each row of a matrix which gives me trouble.
Thanks for any help!

2 Commenti

What is the reference value that you will be comparing X to? The mean of the row? The mean of the entire 2D matrix?
Hi,
Basically I'm looking at the rows individually, so I want to do rms=sqrt(mean(x^2)) for each row.

Accedi per commentare.

 Risposta accettata

rms = sqrt(mean(x.^2,2));

1 Commento

Ah, thank you! For some reason I didn't consider that the mean function accepted the DIM parameter. Man I'm bad with this program.

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by