加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

ARMA模型的Matlab代码

(2008-11-28 09:30:53)
标签:

杂谈

ARMA模型的Matlab代码
来源:http://www.mathworks.com/matlabcentral/fileexchange/16425
%--------------------------------------------------------------------------
%
  ARMA_LAST.M
%
  This function provides an ARMA spectral estimate which is maximum
% entropy satisfying correlation constraint (number of poles)and cepstrum
% constrains (number of ceros)
%
  [sigma,outn,outd]=arma_last(xinf,np,nq)
%
% The function requires:
%
  xinf(nsam)  Input signal (real valued) of nsam samples
  nq          Order of the denominator (# of poles)
  np          Order of the numerator (# of ceros)
%
% The function provides:
%
  outd(nq)    The numerator coefficients outn(1)=1
  outn(np)    The denominator coefficients outd(1)=1
  sigma       The square-root of input noise power
%
% The function requires spa_corc.m to compute the autocorrealtion matrix
% estimate
%
  Miguel Angel LAGUNAS and Petre STOICA                June 2007
%
%--------------------------------------------------------------------------
function [sigma,outn,outd]=arma_last(xinf,np,nq);
nsam=length(xinf);ra1=spa_corc(xinf,nq);nle=(nsam/2);
ra2=spa_corc(xinf,nle);[u d]=eig(ra2);
d1=diag(log(diag(d)));ca1=u*d1*u';clear u d1 d ra2 nsam;
for i=1:np
  cuso(i)=0;
  for j=1:nle-i;
    cuso(i)=cuso(i)+ca1(j,i+j);
  end;cuso(i)=cuso(i)/(nle);
end;
cep=(1:1:np).*cuso(1:np);clear ca1 nle cuso;
i=2;h(1)=1;
while i<np+0.5;
  h(i)=0;
  for k=1:i-1;
    h(i)=h(i)+h(k)*cep(i-k);
  end;
  h(i)=h(i)/(i-1);i=i+1;
end;
hh=flipud(hankel(fliplr(h)));clear h cep;
if nq>np;
   hh=[hh zeros(np,nq-np)];
else;
   hh=hh(1:np,1:nq);
end;
[u d]=eig(ra1,hh'*hh);sas=diag(d);ua=[];sasn=[];
for j=1:nq;
  [auso luso]=min(sas);sasn=[sasn;sas(luso)];
  sas(luso)=10e9;ua=[ua u(:,luso)];
end;
outd=real(ua(:,1)');outd=outd/outd(1);sigma=1/sqrt(sasn(1));
hha=hh/sigma;outn=outd*hha';sigma=sigma*outn(1);outn=outn/outn(1);
clear hh auso luso sas sasn u d ua ra1;
%---------------------------------------------------------------------

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有