Home > wafo > wdemos > rfcdemo1 > armaspec.m

armaspec

PURPOSE Computes the spectral density for an AR- or ARMA-model.

SYNOPSIS [R]=armaspec(C,A,s2,n)

DESCRIPTION ```  ARMASPEC   Computes the spectral density for an AR- or ARMA-model.
The process is governed by the system equation
A(q) * x(t) = C(q) * sqrt(s2) * e(t)

S = armaspec(C,A,s2,n)

S   = Spectral density. [f1 S1; f2 S2; ... fn Sn]
(Frequencies in row 1 and spectral density in row 2.)

C   = Coefficients in C-polynomials. [1 c_1 ... c_nc]
A   = Coefficients in A-polynomials. [1 a_1 ... a_na]
s2  = Innovation variance.
n   = Number of calculated values.

Example: AR(2)-process.
S = armaspec(1,[1 1 0.9],1,500);
plot(S(:,1),S(:,2))
Example: ARMA(4,2)-process.
S = armaspec([1 0.05 -0.88],[1 -2.06 1.64 -0.98 0.41],4.84e-6,500);
plot(S(:,1),S(:,2))```

CROSS-REFERENCE INFORMATION This function calls:
 freqz Digital filter frequency response.
This function is called by:
 rfcdemo1 Demo for switching AR(1)-processes.

SOURCE CODE ```001 function [R]=armaspec(C,A,s2,n)
002
003 % ARMASPEC   Computes the spectral density for an AR- or ARMA-model.
004 %   The process is governed by the system equation
005 %     A(q) * x(t) = C(q) * sqrt(s2) * e(t)
006 %
007 % S = armaspec(C,A,s2,n)
008 %
009 %
010 % S   = Spectral density. [f1 S1; f2 S2; ... fn Sn]
011 %       (Frequencies in row 1 and spectral density in row 2.)
012 %
013 % C   = Coefficients in C-polynomials. [1 c_1 ... c_nc]
014 % A   = Coefficients in A-polynomials. [1 a_1 ... a_na]
015 % s2  = Innovation variance.
016 % n   = Number of calculated values.
017 %
018 % Example: AR(2)-process.
019 %   S = armaspec(1,[1 1 0.9],1,500);
020 %   plot(S(:,1),S(:,2))
021 % Example: ARMA(4,2)-process.
022 %   S = armaspec([1 0.05 -0.88],[1 -2.06 1.64 -0.98 0.41],4.84e-6,500);
023 %   plot(S(:,1),S(:,2))
024
025 % Copyright (c) 1997 by Pär Johannesson
026 % Toolbox: Rainflow Cycles for Switching Processes V.1.0, 2-Oct-1997
027
028 [H,w]=freqz(C,A,n);
029 R=real(s2*H.*conj(H));
030 f=w/(2*pi);
031
032 R = [f R];
033```

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group

Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003