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 Comments

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.

Sign in to comment.

 Accepted Answer

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

1 Comment

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.

Sign in to comment.

More Answers (0)

Categories

Asked:

on 9 Feb 2014

Commented:

on 9 Feb 2014

Community Treasure Hunt

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

Start Hunting!