Home > NoiseTools > nt_rms.m

nt_rms

PURPOSE ^

RMS - Root-mean-square

SYNOPSIS ^

function y=rms(x, dim)

DESCRIPTION ^

RMS - Root-mean-square
 
  y=rms(x): If x is a matrix the rms is calculated columnwise.
  y=rms(x,dim): calculate rms according to dim.
 
  see also nt_bsrms, nt_bsplot

 NoiseTools

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function y=rms(x, dim)
0002 %RMS - Root-mean-square
0003 %
0004 %  y=rms(x): If x is a matrix the rms is calculated columnwise.
0005 %  y=rms(x,dim): calculate rms according to dim.
0006 %
0007 %  see also nt_bsrms, nt_bsplot
0008 %
0009 % NoiseTools
0010  
0011 % if row vector transpose to column
0012 if size(x,1) == 1 ; x = x'; end
0013  
0014 if nargin == 2
0015     if dim == 0; 
0016         y=sqrt(sum(sum(x.^2))/prod(size(x)));
0017     else
0018         y=sqrt(sum(x.^2,dim)/size(x,dim));
0019     end
0020 else
0021     y=sqrt(sum(x.^2)/size(x,1));
0022 end

Generated on Sat 29-Apr-2023 17:15:46 by m2html © 2005