aarls.m

来自「Adaptive Filtering Primer with MATLAB」· M 代码 · 共 30 行

M
30
字号
function [w,J]=aarls(L,var2,h,N,h1,lambda,delta,I);
%L=No. of iterations;
%var2=Variance of the plant noise;
%h=Plant impulse response;
%N=Length of the Adaptive Filter;
%h1=Coloring filter impulse response;
%lambda=Forgetting factor in the RLS algorithm;
%delta=Parameter in the RLS algorithm;
%I=No. of runs to be used for ensemble averaging;
J=zeros(L,1);
for k=1:I
    x1=randn(L,1);	x=filter(h1,1,x1);
    v=sqrt(var2)*randn(L,1); d=filter(h,1,x)+v;
	w=zeros(N,1);   xd=zeros(N,1);
	R_inv=(1/delta)*eye(N);
	for n=1:L
		xd=[x(n);xd(1:length(xd)-1)];
		gbar=R_inv*xd;
		g=gbar/(lambda+xd'*gbar);
		y=w'*xd;
		e=d(n)-y;
		w=w+g*e;
		R_inv=(1/lambda)*(R_inv-g*gbar');
		J(n)=J(n)+e^2;
	end
end
J=J/I;
nn=0:L-1;plot(nn,10*log10(J));
xlabel('Iteration no.');ylabel('MSE in dB');
end

⌨️ 快捷键说明

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