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

14 views (last 30 days)
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
Image Analyst
Image Analyst on 9 Feb 2014
What is the reference value that you will be comparing X to? The mean of the row? The mean of the entire 2D matrix?
Matthew
Matthew on 9 Feb 2014
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

the cyclist
the cyclist on 9 Feb 2014
rms = sqrt(mean(x.^2,2));
  1 Comment
Matthew
Matthew on 9 Feb 2014
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

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!