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

📄 statup.m

📁 GPS software toolbox for GPS receiver development
💻 M
字号:
%                             statup.m
%  Scope:  This MATLAB macro computes the running mean, standard
%          deviation and root mean square for a set of real samples.
%  Usage:  [np1,am,astd,arms] = statup(np1,xnp1,am,astd,arms)
%  Description of parameters:
%          np1  - input, number of samples of the old set is  np1 - 1
%          xnp1 - input, latest sample to be added to the old set to form
%                 the new set
%          am   - input, mean of the old set
%          astd - input, standard deviation of the old set of samples
%          arms - input, root mean square of the old set of samples
%          np1  - output, number of samples of the new set
%          am   - output, mean of the new set
%          astd - output, standard deviation of the new set of samples
%          arms - output, root mean square of the new set of samples
%  Remarks:
%          1) np1 should be greater or equal to 1.
%          2) The first call to this module should be with np1=1, for
%             the initialization - when the computation of running mean,
%             standard deviation and mean square root is beginning.
%  Last update:  09/27/00
%  Copyright (C) 1996-00  by LL Consulting. All Rights Reserved.

function [np1,am,astd,arms] = statup(np1,xnp1,am,astd,arms)

if np1 == 1
   am = xnp1;
   astd = 0.;
   arms = 0.;
   np1 = 2;
   return
end

amnew = am + (xnp1 - am)/np1;
n = np1 - 1;
nm1 = n - 1;
temp1 = (xnp1 - amnew)*(xnp1 + amnew);
temp2 = (am - amnew)*(am + amnew);
temp = (nm1*astd*astd + temp1 + n*temp2)/n;
if  temp <= 0.
   disp('Error 1 - STATUP.M; numerically incorrect value ');
   return
else
   astdnew = sqrt(temp);
end
temp = (nm1*arms*arms + temp1 + am*am)/n;
if  temp <= 0.
   disp('Error 2 - STATUP.M; numerically incorrect value ');
   
else
   armsnew = sqrt(temp);
end 

am = amnew;
astd = astdnew;
arms = armsnew;
np1 = np1 + 1;

⌨️ 快捷键说明

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