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

📄 bianbuchanglms.m

📁 变步长LMS算法
💻 M
字号:
clc;
clear all
N=1000;
u=0.0002;
umax=0.1;
umin=0.0000002;
p=0.0965;
%p=1;
v=wgn(1,N,p);
x(1)=v(1);
x(2)=0.2*x(1)+v(2);
for n=3:N;
    x(n)=0.2*x(n-1)-0.9*x(n-2)+v(n); 
end;
w1(3)=0;
w2(3)=0;
ww1(2)=0;
ww1(3)=0;
ww2(3)=0;
for n=3:N-1;
    e(n)=x(n)-x(n-1)*ww1(n)-x(n-2)*ww2(n);
    ww1(n+1)=ww1(n)+u*x(n-1)*e(n);
    ww2(n+1)=ww2(n)+u*x(n-2)*e(n);
end;
uu=zeros(1,N);
uu(1)=umax;
uu(2)=umax;
uu(3)=umax;
p=zeros(1,N);
A=zeros(1,N);
p(1)=umax;
p(2)=umax;
alpha=0.9;
gama=0.000001;
B=0.9;
e(2)=x(2)-x(1)*ww1(2);
e(1)=x(1);
W1=zeros(1,N);
W2=zeros(1,N);
t=1;
L=10;
for i=1:t
for n=3:N-1;
    e(n)=x(n)-x(n-1)*w1(n)-x(n-2)*w2(n);
    qiuhe=0;
    for j=1:L
        if n-j+1>0
           qiuhe=qiuhe+exp(-j+1)*e(n-j+1)^2;
        else break;
        end
    end
    p(n)=B*p(n-1)+(1-B)*(e(n)*e(n-1)+qiuhe);
    A(n)=alpha*uu(n)+gama*p(n)^2;
    uu(n+1)=A(n);
    if rem(n,L)==0
       if     uu(n+1)>umax
              uu(n+1)=umax;
       elseif uu(n+1)<umin
              uu(n+1)=umin;
       else   uu(n+1)=uu(n+1);
       end
    else uu(n+1)=uu(n);
    end
    w1(n+1)=w1(n)+uu(n+1)*x(n-1)*e(n);
    w2(n+1)=w2(n)+uu(n+1)*x(n-2)*e(n);
end;
W1=w1+W1;
W2=w2+W2;
end
w1=W1/t;
w2=W2/t;
figure;
plot(w1,'r');
title('W1的图象');
hold on
plot(ww1,'b');
figure;
plot(w2,'r');
title('W2的图象');
hold on
plot(ww2,'b')

⌨️ 快捷键说明

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