testblms.m

来自「卡尔曼滤波器设计的一个例子」· M 代码 · 共 41 行

M
41
字号
% BLMS used in a simple system identification application.
% By the end of this script the adaptive filter w 
% should have the same coefficients as the unknown filter h.
clear all;
iter = 5000;                   % Number of samples to process
% Complex unknown impulse response
h    = [.9 + i*.4; 0.7+ i*.2; .5; .3+i*.1; .1];    
xt   = 2*(rand(iter,1)-0.5);   % Input signal, zero mean random.
%xt   = filter(.4, [1 -.6], xt);
% although xn is real, dn will be complex since h is complex
dt   = filter(h,1,xt);         % Unknown filter output 
en   = zeros(iter,1);          % vector to collect the error

% Initialize BLMS with a filter of 5 coef.
L = 5;
N = 10;
[w,x,dn,e,y]=init_blms(N,L);

%% Processing Loop
for (m=1:L:iter-L)
   xn = xt(m:m+L-1,:);
   dn = dt(m:m+L-1,:)+ 1e-3*rand; 
   
   % call BLMS to calculate the filter output, estimation error
   % and update the coefficients. 
   [w,x,y,e]=asptblms(x,xn,dn,w,0.05,'srlms');

   % save the last error block to plot later
   en(m:m+L-1,:) = e;  
end;

% display the results
subplot(2,2,1);stem([real(w) -imag((w))]); grid;
xlabel('filter after convergence')
subplot(2,2,2);
eb = filter(0.1, [1 -0.9], en(1:m) .* conj(en(1:m)));
plot(10*log10(eb +eps ));grid
axis([0 5000 -80 0]);
ylabel('estimation error [dB]')
xlabel('Learning curve')

⌨️ 快捷键说明

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