1 function [MX,res,arg3,acf] = rc2ar(rc);
2 % converts reflection coefficients into autoregressive parameters
3 % uses the Durbin-Levinson recursion for multiple channels
4 % function [AR,RC,PE,ACF] = rc2ar(RC);
5 % function [MX,PE] = rc2ar(RC);
8 % RC reflection coefficients
11 % AR autoregressive model parameter
12 % RC reflection coefficients (= -PARCOR coefficients)
13 % PE remaining error variance (relative to PE(1)=1)
14 % MX transformation matrix between ARP and RC (Attention: needs O(p^2) memory)
15 % arp=MX(:,K*(K-1)/2+(1:K));
16 % rc =MX(:,(1:K).*(2:K+1)/2);
18 % All input and output parameters are organized in rows, one row
19 % corresponds to the parameters of one channel
21 % see also ACOVF ACORF DURLEV AR2RC
24 % P.J. Brockwell and R. A. Davis "Time Series: Theory and Methods", 2nd ed. Springer, 1991.
25 % S. Haykin "Adaptive Filter Theory" 3rd ed. Prentice Hall, 1996.
26 % M.B. Priestley "Spectral Analysis and Time Series" Academic Press, 1981.
27 % W.S. Wei "Time Series Analysis" Addison Wesley, 1990.
29 % $Id: rc2ar.m 5090 2008-06-05 08:12:04Z schloegl $
30 % Copyright (c) 1996-2002,2007,2008 by Alois Schloegl <a.schloegl@ieee.org>
31 % This function is part of the TSA-toolbox
32 % http://www.dpmi.tu-graz.ac.at/~schloegl/matlab/tsa/
34 % This program is free software: you can redistribute it and/or modify
35 % it under the terms of the GNU General Public License as published by
36 % the Free Software Foundation, either version 3 of the License, or
37 % (at your option) any later version.
39 % This program is distributed in the hope that it will be useful,
40 % but WITHOUT ANY WARRANTY; without even the implied warranty of
41 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 % GNU General Public License for more details.
44 % You should have received a copy of the GNU General Public License
45 % along with this program. If not, see <http://www.gnu.org/licenses/>.
50 res=[ones(lr,1) zeros(lr,lc)];
51 if nargout<3 % needs O(p^2) memory
52 MX=zeros(lr,lc*(lc+1)/2);
55 % Durbin-Levinson Algorithm
57 MX(:,idx+K)=rc(:,K);%(AutoCov(:,K+1)-d)./res(:,K);
59 if K>1 %for compatibility with OCTAVE 2.0.13
60 MX(:,idx+(1:K-1))=MX(:,(K-2)*(K-1)/2+(1:K-1))-MX(:,(idx+K)*ones(K-1,1)).*MX(:,(K-2)*(K-1)/2+(K-1:-1:1));
62 res(:,K+1) = res(:,K).*(1-abs(MX(:,idx+K)).^2);
65 %arp=MX(:,K*(K-1)/2+(1:K));
66 %rc =MX(:,(1:K).*(2:K+1)/2);
67 ACF=cumprod(ones(lr,lr)-rc.^2,2);
69 else % needs O(p) memory
71 acf=[ones(lr,1),zeros(lr,lc)];
72 %rc=RC; %zeros(lr,lc-1);
74 % Durbin-Levinson Algorithm
76 acf(:,K) = -sum(acf(:,K:-1:1).*ar(:,1:K),2);
78 if K>1, %for compatibility with OCTAVE 2.0.13
79 ar(:,1:K-1) = ar(:,1:K-1) - ar(:,K*ones(K-1,1)) .* ar(:,K-1:-1:1);
81 res(:,K+1) = res(:,K) .* (1-abs(ar(:,K)).^2);
84 ACF=cumprod(ones(lr,lc)-rc.^2,2);
86 % assign output arguments