📄 7-6.m
字号:
%例程7-6 自适应噪声对消器
%自适应噪声对消器
clear all
clc
t=0:1/1000:10-1/1000;
s=sin(2*pi*t);
snr=10;
s_power=var(s); %var函数: 返回方差值
linear_snr=10^(snr/10);
factor=sqrt(s_power/linear_snr);
noise=randn(1,length(s))*factor;
x=s+noise; %由SNR计算随机噪声
x1=noise; %噪声源输入
x2=noise;
w1=0; %权系数初值
w2=0;
e=zeros(1,length(x));
y=0;
u=0.05;
for i=1:10000 %LMS算法
y=w1*x1(i)+w2*x2(i);
e(i)=x(i)-y;
w1=w1+u*e(i)*x1(i);
w2=w2+u*e(i)*x2(i);
end
figure(1)
subplot(3,1,1)
plot(t,x);
title('带噪声正弦信号')
axis([0 10 -1.2 1.2]);
subplot(3,1,2)
plot(t,noise);
title('噪声信号')
axis([0 10 -1.2 1.2]);
subplot(3,1,3)
plot(t,e);
title('自适应噪声对消器')
axis([0 10 -1.2 1.2]);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -