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

📄 rwalk.m

📁 GPS software toolbox for GPS receiver development
💻 M
字号:
%                             rwalk.m
%  Scope:   This MATLAB macro generates a random walk process.
%  Usage:   x = rwalk(n,qdt,iseed)  when the seed is reset to iseed value
%           x = rwalk(n,qdt) 
%  Description of parameters:
%           n     - input, number of random numbers to be generated
%           qdt   - input, noise covariance  q*dt
%           iseed - input, initial value of the seed (optional); if it 
%                   is specified the seed is reset to iseed value
%           x     - output, random walk process with  n  elements
%  Method:
%           Direct implementation of the formula
%              x_new = x_old + w
%           where
%              w  is a normally distributed random number with zero 
%              mean and standard deviation equals to  qdt
%  External Matlab macros used:  genrn
%  Last update:  06/27/00
%  Copyright (C) 1996-00 by LL Consulting. All Rights Reserved.

function  x = rwalk(n,qdt,iseed)

if ( (nargin < 2) | (nargin > 3) )
   disp('Error - RWALK.m  - check the argument list');
   disp('  ');
   return
elseif  (nargin == 3)
   rand('seed',iseed);  
end

clear x
x = zeros(n,1);

x(1) = 0.;            %  initialization of the random walk process
if  n >= 2
   for  k = 2:n
      x(k) = x(k-1) + genrn(1,0.,qdt);
   end
end

⌨️ 快捷键说明

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