rms2.m

来自「GPS TOOLBOX包含以下内容: 1、GPS相关常量和转换因子; 2、角」· M 代码 · 共 30 行

M
30
字号
%                           rms2.m
%  Scope:   This MATLAB macro computes modified root mean square (modified RMS) 
%           of a sample.
%  Usage:   y = rms2(x)
%  Description of parameters:
%           x  -  input, sample (row or column) vector with  m  elements
%           y  -  output, RMS2 value, i.e.  square root of (sum of squares
%                 normalized by number of elements)
%  Remark:  The modified RMS is identical to the textbook RMS when the sum of all
%           sample elements is zero.
%  Last update:    09/27/00
%  Copyright (C) 1996-00 by LL Consulting. All Rights Reserved.

function  y = rms2(x)

[m,n] = size(x);
if  n ~= 1
   x = x';
   m = n;
end
if  m == 1
   y = 0.;
else
   y = 0.;
   for  i = 1:m
      y = x(i) * x(i) + y;
   end
   y = sqrt(y/m);
end
                                

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?