]> Creatis software - CreaPhase.git/blob - octave_packages/tsa-4.2.4/poly2rc.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / tsa-4.2.4 / poly2rc.m
1 function [RC,r0] = poly2rc(a,efinal);
2 % converts AR-polynomial into reflection coefficients
3 % [RC,R0] = poly2rc(A [,Efinal])
4 %
5 %  INPUT:
6 % A     AR polynomial, each row represents one polynomial
7 % Efinal    is the final prediction error variance (default value 1)
8 %
9 %  OUTPUT
10 % RC    reflection coefficients
11 % R0    is the variance (autocovariance at lag=0) based on the 
12 %       prediction error
13 %
14 %
15 % see also ACOVF ACORF AR2RC RC2AR DURLEV AC2POLY, POLY2RC, RC2POLY, RC2AC, AC2RC, POLY2AC
16
17 %       $Id: poly2rc.m 5090 2008-06-05 08:12:04Z schloegl $
18 %       Copyright (C) 1998-2002,2008 by Alois Schloegl <a.schloegl@ieee.org>
19 %
20 %    This program is free software: you can redistribute it and/or modify
21 %    it under the terms of the GNU General Public License as published by
22 %    the Free Software Foundation, either version 3 of the License, or
23 %    (at your option) any later version.
24 %
25 %    This program is distributed in the hope that it will be useful,
26 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
27 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28 %    GNU General Public License for more details.
29 %
30 %    You should have received a copy of the GNU General Public License
31 %    along with this program.  If not, see <http://www.gnu.org/licenses/>.
32
33 if all(size(a))>1,
34         fprintf(2,'Error poly2rc: "a" must be a vector\n');
35         return;
36 end;
37 a=a(:).';
38
39 mfilename='POLY2RC';
40 if ~exist('ar2rc','file')
41         fprintf(2,'Error %s: AR2RC.M not found. \n Download TSA toolbox from http://www.dpmi.tu-graz.ac.at/~schloegl/matlab/tsa/\n',mfilename);
42         return;
43 end;
44
45 if nargin<2, efinal=1; end;
46
47 [AR,RC,PE] = ar2rc(poly2ar(a));
48 if nargout>1,
49         r0=efinal.*PE(:,1)./PE(:,size(PE,2));
50 end;