⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iir4.m

📁 这是自适应信号处理的几个matlab程序
💻 M
字号:

%IIR4 Problem 1.2.4
%
%   'ifile.mat' - input file containing:
%      I - members of ensemble
%      K - iterations
%      sigmax - standard deviation of input
%      thetaao, thetabo - coefficient vectors of plant
%      sigman - standard deviation of measurement noise
%      mu - convergence factor
% 
%   'ofile.mat' - output file containing:
%      ind - sample indexes 
%      MSE - mean-square error 

clear all	% clear memory
load ifile;	% read input variables
N=length(thetaao);	% plant and filter den. order
M=length(thetabo)-1;	% plant and filter num. order
N1=N+1;
M1=M+1;			% auxiliary parameters
MSE=zeros(K,1);		% prepare to accumulate MSE*I
NS=round(N/2);		% sections

for i=1:I,		% ensemble
   X=zeros(N+1,1);	% initial input vector
   S=zeros(3,NS+1);	% partial memories
   D1=zeros(N,1);	% desired signal initial memory
   thetaa=zeros(2,NS);
   thetab=[0 ones(1,NS-1);
           zeros(2,NS)];% initial coefficient vectors
   Ia=zeros(3*NS,NS);
   Ib=zeros(3*NS,NS);	% intermediate registers
   psiae=zeros(3,NS);	
   psib=zeros(3,NS);	% initial signal inform. vectors
   x=(rand(K,1)*2-1)*sqrt(3)*sigmax;
			% input
   n=randn(K,1)*sigman;	% measurement noise 
   for k=1:K,		% iterations
      X=[x(k)
         X(1:N)];	% new input vector
      d=[thetaao;thetabo]'*[D1;X];
			% desired signal sample
      D1=[d
          D1(1:(N-1))];	% new desired signal memory
      s=x(k);		% input to first partial memory
      e=d+n(k);		% noisy desired signal sample
      for m=1:NS,	% sections
         S(:,m)=[s
                 S(1:2,m)];
         s=[thetaa(:,m);thetab(:,m)]'*[S(1:2,m+1)
                                        S(:,m)];
         ia=S(1,m+1)+thetaa(:,m)'*Ia(1:2,m);
         Ia(1:3,m)=[ia
                    Ia(1:2,m)];
         ib=S(1,m)+thetaa(:,m)'*Ib(1:2,m);
         Ib(1:3,m)=[ib
                    Ib(1:2,m)];
         if m<NS, 
      	    for l=m+1:NS,
               ia=[thetaa(:,l);thetab(:,l)]'*[Ia((1:2)+(l-m)*3,m)
                                               Ia((1:3)+(l-1-m)*3,m)];
               Ia((1:3)+(l-m)*3,m)=[ia
                                    Ia((1:2)+(l-m)*3,m)];
               ib=[thetaa(:,l);thetab(:,l)]'*[Ib((1:2)+(l-m)*3,m)
                                               Ib((1:3)+(l-1-m)*3,m)];
               Ib((1:3)+(l-m)*3,m)=[ib
                                    Ib((1:2)+(l-m)*3,m)];
            end
         end
         psiae(:,m)=-Ia((1:3)+(NS-m)*3,m);
         psib(:,m)=-Ib((1:3)+(NS-m)*3,m);
			% new signal inform. vectors
      end
      S(:,NS+1)=[s
                 S(1:2,NS+1)];
      e=e-s;		% error sample
      MSE(k)=MSE(k)+e^2;	% accumulate MSE*I
      thetaa=thetaa-mu*e*psiae(1:2,:);
      thetab=thetab-mu*e*psib;	% new coefficient vectors
      %
      % stability test
      for m=1:NS,
         if (((1+thetaa(1,m)-thetaa(2,m))<0)|((1-thetaa(1,m)-thetaa(2,m))<0)|(abs(thetaa(2,m))>1)),
            thetaa(2,m)=1/thetaa(2,m);
            thetaa(1,m)=thetaa(1,m)/teta(2,m);
         end
      end
   end
end

ind=0:(K-1);		% sample indexes
MSE=MSE/I;		% calculate MSE
save ofile ind MSE;	% write output variables

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -