⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rms.m

📁 GPS software toolbox for GPS receiver development
💻 M
字号:
%                           rms.m
%  Scope:   This MATLAB macro computes root mean square (RMS) of a sample.
%  Usage:   y = rms(x)
%  Description of parameters:
%           x  -  input, sample (row or column) vector with  m  elements
%           y  -  output, RMS value (normalized by  m-1); if the sample 
%                 vector has only one element then the result is 0.
%  Last update:  09/27/00
%  Copyright (C) 1996-00 by LL Consulting. All Rights Reserved.

function  y = rms(x)

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

⌨️ 快捷键说明

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