summaryrefslogtreecommitdiff
path: root/macros/poly2ac.sci
blob: 8b74b5c8c7473c6e223a940fc0e5aa4a081083b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function r = poly2ac(a,efinal)
// Convert prediction polynomial to autocorrelation sequence.
//Run rlevinson.sci before running this
// Calling Sequence
// R = poly2ac(a,efinal)
// 
// Parameters
// a: input prediction polynomial with 1st element 1 (if not, poly2ac normalizes it to 1 before proceeding).
// efinal: input prediction error
// r: output autocorrelation sequence
//
// Description
// This function obtains the underlying autocorrelation sequence that would best fit a linear prediction filter described by the
// denominator polynomial and the numerator scaling. The filter is H(z) = efinal/(a(1) + a(2) x z a(3) x z^2 ... a(n) x z^n-1)
// 
// Examples
//   a = [1.0000 0.4288 0.76 0.0404 -0.02];
//   efinal = 0.2;           // Step prediction error
//   r = poly2ac(a,efinal)   // Autocorrelation sequence
//
// See also
// ac2poly 
// poly2rc 
// rc2poly 
// rc2ac
// ac2rc 
//
// Author: Parthe Pandit
//
// Bibliography
// S. Kay, Modern Spectral Estimation, Prentice Hall, N.J., 1987, Chapter 6.

    //errcheck 1: Check for input format of polynomial
   if (size(a,1) > 1 & size(a,2) > 1)  then
      error("Input polynomial has to be a 1-dimensional array")
    end
    if (length(efinal) > 1)  then
        error("Input efinal has to be a scalar")
    end
         r = rlevinson(a,efinal);
   
endfunction