📄 lms_test.m
字号:
%主函数
%XS是周期性信号
%XN是干扰信号
%
clear
for repeat=1:100
t=0:0.1:999.9;
xs=(5*sin(0.05*t))';
xn=(sqrt(0.5)*randn(1,length(t)))';
d=xs;
x=xs+xn;
figure(1);
subplot(311);
plot(t,xs);grid;
ylabel('幅度');
title('\it{输入周期性信号}');
subplot(312);
plot(t,xn);grid;
ylabel('幅度');
xlabel('时间');
title('\it{随机噪声信号}');
subplot(313);
plot(t,x);grid;
ylabel('幅度');
xlabel('时间');
title('\it{加入噪声的信号}');
N=20;
w=(zeros(1,N))';
M=length(x);
mu=3.2098e-006;
%mu=0.004;
y=(zeros(1,M))';
e=(zeros(1,M))';
%sum1=zeros(N,N);
%sum2=zeros(N,1);
for n=N:M
x1=x(n:-1:n-N+1);
y(n)=w'*x1;
e(n)=d(n)-y(n);
w=w+mu*x1*conj(e(n));
end %for n=N:M
E(:,repeat)=e';
end %for repeat
figure(2);
plot(t,y);
axis([0,1000,-10,10]);grid;
figure(3);
semilogy(mean((E').^2),'r-.');grid;
%plot(mean((E.^2)'));grid;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -