nlms_main.m

来自「基于变步长LMS在干扰抵消中的应用」· M 代码 · 共 25 行

M
25
字号
syorder=5;
N=10000;
sig=randn(N,1);
[b,a]=butter(2,0.25);
h=[0.0976;0.2873;0.3360;0.2210;0.0964;];
signal=filter(b,a,sig);
n=randn(N,1);
n=n*std(signal)/(10*std(n));
signal=signal+n;
N_learn=100;
[y,w]=nlms(sig(1:N_learn),syorder,signal(1:N_learn));
for n=N_learn+1:N
u=sig(n:-1:n-syorder+1);
y(n)=w'*u;
e(N)=signal(n)-y(n);
end
figure(1);plot(signal);hold on ;plot(y,'r');
xlabel('samples');ylabel('true and estimated output');
figure(2);semilogy((abs(e)));
title('Errr curve');
xlabel('sample');ylabel('error value');
figure(3);plot(h,'k+');
hold on ;plot(w,'r*');
legend('avtual weights','estimated weight');
title('compqrison of the actual weights and the estimated weights');

⌨️ 快捷键说明

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