# RMS of a 3d matrix in MATLAB

1. Jun 2, 2010

### sasikanth

I have a 4072x22x10 matrix. I am trying to calculate the RMS of the 4072x22 matrix but am unable to do so. The worst case scenario would be to individually calculate the RMS value of each element but that would require a number of loops and I don't want to do so. Is there any easier way to get the result of a 4072x22 matrix??

2. Jun 2, 2010

### MRFMengineer

Why can you not do it now? Do you run out of memory?

Maybe I am wrong, but can't you just:
A = 4072X22X10 matrix

B = A(:,:,1)
rms = sqrt (mean(B(^2 + std(B(^2)

3. Jun 2, 2010

### sasikanth

This might work, but I am looking for the RMS of not A(:,:,1), but all the 10 matrices..basically i have 10 4072x22 matrices put together in 1 3d matrix and I want the RMS of these 10 4072x22 matrices as one matrix..

4. Jun 2, 2010

### MRFMengineer

This will return a single value for the rms of all elements of A. Or do you want the rms of each of the 10 matricies?

A = 4072X22X10 matrix

rms = sqrt (mean(A(^2 + std(A(^2)

5. Jun 2, 2010

### sasikanth

This returns a single value but thats not what I want. I want the rms of each of the 10 matrices, result to be a 4072x22 matrix.

6. Jun 2, 2010

### MRFMengineer

If your desired output is one 4072X22 matrix, try:

B = mean(A,3)

hmm, only seems to work for mean, not std. Might need some more code to help Matlab along.