How to Efficiently Calculate the RMS of a Large 3D Matrix in MATLAB?

Click For Summary

Discussion Overview

The discussion centers around calculating the root mean square (RMS) of a large 3D matrix in MATLAB, specifically a 4072x22x10 matrix. Participants explore methods to efficiently compute the RMS without resorting to extensive looping, focusing on both theoretical approaches and practical coding solutions.

Discussion Character

  • Technical explanation, Mathematical reasoning, Debate/contested

Main Points Raised

  • One participant expresses difficulty in calculating the RMS of a 4072x22 matrix derived from a larger 3D matrix and seeks a more efficient method.
  • Another participant suggests a method to calculate the RMS for a single slice of the matrix, questioning if memory limitations are an issue.
  • A participant clarifies that they want the RMS calculated across all 10 matrices, not just one slice.
  • There is a proposal to calculate the RMS for the entire 3D matrix, but it is noted that this would yield a single value rather than the desired 4072x22 output.
  • A later reply suggests using the mean function to reduce the matrix but notes that additional coding may be necessary for standard deviation calculations.

Areas of Agreement / Disagreement

Participants do not reach a consensus on a single method for calculating the RMS of each of the 10 matrices. Multiple approaches are proposed, but no agreement is found on a definitive solution.

Contextual Notes

Limitations include the need for additional code to compute the standard deviation across the third dimension of the matrix, as well as potential memory constraints when handling large data sets.

Who May Find This Useful

Readers interested in MATLAB programming, particularly those working with large multidimensional arrays and seeking efficient computational methods.

sasikanth
Messages
9
Reaction score
0
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??
 
Physics news on Phys.org
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)
 
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..
 
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)
 
This returns a single value but that's not what I want. I want the rms of each of the 10 matrices, result to be a 4072x22 matrix.
 
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.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K