summaryrefslogtreecommitdiff
path: root/macros/poly2ac.sci
diff options
context:
space:
mode:
authorshamikam2017-11-07 15:59:48 +0530
committershamikam2017-11-07 15:59:48 +0530
commitc0c0582462720ed597b00e116506570577614e89 (patch)
tree31dedd23698e5357b19c810b7d7a8464100ef44a /macros/poly2ac.sci
downloadFOSSEE-Signal-Processing-Toolbox-c0c0582462720ed597b00e116506570577614e89.tar.gz
FOSSEE-Signal-Processing-Toolbox-c0c0582462720ed597b00e116506570577614e89.tar.bz2
FOSSEE-Signal-Processing-Toolbox-c0c0582462720ed597b00e116506570577614e89.zip
initial commit
Diffstat (limited to 'macros/poly2ac.sci')
-rw-r--r--macros/poly2ac.sci42
1 files changed, 42 insertions, 0 deletions
diff --git a/macros/poly2ac.sci b/macros/poly2ac.sci
new file mode 100644
index 0000000..8b74b5c
--- /dev/null
+++ b/macros/poly2ac.sci
@@ -0,0 +1,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