Mercurial > hg > octave-nkf
diff scripts/signal/arch_rnd.m @ 11469:c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Sun, 09 Jan 2011 12:41:21 -0800 |
parents | a4f482e66b65 |
children | 1740012184f9 |
line wrap: on
line diff
--- a/scripts/signal/arch_rnd.m +++ b/scripts/signal/arch_rnd.m @@ -41,7 +41,7 @@ ## Author: KH <Kurt.Hornik@wu-wien.ac.at> ## Description: Simulate an ARCH process -function y = arch_rnd (a, b, T) +function y = arch_rnd (a, b, t) if (nargin != 3) print_usage (); @@ -50,7 +50,7 @@ if (! ((min (size (a)) == 1) && (min (size (b)) == 1))) error ("arch_rnd: a and b must both be scalars or vectors"); endif - if (! (isscalar (T) && (T > 0) && (rem (T, 1) == 0))) + if (! (isscalar (t) && (t > 0) && (rem (t, 1) == 0))) error ("arch_rnd: T must be a positive integer"); endif @@ -72,17 +72,17 @@ b = [b, 0]; lb = lb + 1; endif - M = max([la, lb]); + m = max([la, lb]); - e = zeros (T, 1); - h = zeros (T, 1); - y = zeros (T, 1); + e = zeros (t, 1); + h = zeros (t, 1); + y = zeros (t, 1); h(1) = a(1); e(1) = sqrt (h(1)) * randn; y(1) = b(1) + e(1); - for t = 2:M + for t = 2:m ta = min ([t, la]); h(t) = a(1) + a(2:ta) * e(t-ta+1:t-1).^2; e(t) = sqrt (h(t)) * randn; @@ -90,14 +90,14 @@ y(t) = b(1) + b(2:tb) * y(t-tb+1:t-1) + e(t); endfor - if (T > M) - for t = M+1:T + if (t > m) + for t = m+1:t h(t) = a(1) + a(2:la) * e(t-la+1:t-1).^2; e(t) = sqrt (h(t)) * randn; y(t) = b(1) + b(2:lb) * y(t-tb+1:t-1) + e(t); endfor endif - y = y(1:T); + y = y(1:t); endfunction