Home > atmlab > math > rms.m

rms

PURPOSE ^

RMS Calculate root mean square (RMS)

SYNOPSIS ^

function y = rms(x)

DESCRIPTION ^

 RMS Calculate root mean square (RMS)

 This function squares all elements of x, sums them up, divides by
 the number of elements, and takes the root.

 Input x can be a vector, matrix, or higher order tensor, the
 output is always a scalar

 FORMAT y = rms(x)

 OUT    y    RMS value
 IN     x      Input vector or matrix

 2008-09-02 Created by Stefan Buehler

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

rms.m

SOURCE CODE ^

0001 % RMS Calculate root mean square (RMS)
0002 %
0003 % This function squares all elements of x, sums them up, divides by
0004 % the number of elements, and takes the root.
0005 %
0006 % Input x can be a vector, matrix, or higher order tensor, the
0007 % output is always a scalar
0008 %
0009 % FORMAT y = rms(x)
0010 %
0011 % OUT    y    RMS value
0012 % IN     x      Input vector or matrix
0013 %
0014 % 2008-09-02 Created by Stefan Buehler
0015  
0016 function y = rms(x)
0017 
0018 xs = x(:) .* x(:);
0019 
0020 s  = sum(xs) / length(x(:));
0021 
0022 y  = sqrt(s);
0023

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005