?? rwalk.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 + -