How to get the RMS value of a matrix?

1.1k Views Asked by At

I have a column matrix $A$ . I need to find the RMS value of it.

To add a scalar, I do $A$=$A+k$
To multiply a scalar, I do $A$=$A.*k$ To get RMS, I have a way which is running a loop -

for n=1:N
count=count+A(n)*A(n);
end

But, I have a large value of $N$ and nested loops. So, It's gonna take a real long time. Is there any short way? Thanks in advance.

1

There are 1 best solutions below

4
On BEST ANSWER

Is it Matlab? If so, Just do

rms=sqrt(A'*A);

It should work.

Why? $A'$ is nothing but the transpose of $A$. So, If $A=[a1,a2,a3..an]$ , then $A'$ is the column matrix of the same values. Multiplying will give - $a1^2+a2^2..$