Calculate RMS of a 4072x22x10 matrix along the third dimension in MATLAB

Join the discussion
Registration is free. Start your own thread to ask a follow-up.
5 replies · 7K views
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.