matlab2drms

2D RMS calculation


I am trying to calculate the rms of some 2D matices, but am unsure if my approach is correct:

Rrms = sqrt( sum(sum((Z1 - mean(mean(Z1))).^2 )) /(wk*wl) )

(where Z1 is a matrix with size wk * wl)

Is this correct, and if not, what should I use?


Solution

  • According to Root Mean Square definition it's just square root of sum of squared values. In terms of Matlab code it will be.

    R = sqrt(sum(sum(Z.^2))/prod(size(Z)))
    

    Another way is to use rms function from signal processing toolbox.