📄 7-13.m
字号:
%例程7-13自适应陷波滤波器
%自适应陷波器仿真
clear all
clc
N=400; %总采样长度
t=0:N-1;
s=sin(2*pi*t/20); %原始正弦信号
A=0.5; %干扰信号的幅值
fai=pi/3; %干扰信号的相移
n=A*cos(2*pi*t/10+fai); %干扰信号
x=s+n; %引入正弦单频干扰的原始输入
x1=cos(2*pi*t/10); %参考输入1
x2=sin(2*pi*t/10); %参考输入2
w1=0.1;
w2=0.1; %权矢量初值
e=zeros(1,N);
y=0;
u=0.05;
for i=1:N %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
subplot(4,1,1);
plot(t,s);
title('原始正弦信号');
subplot(4,1,2);
plot(t,x);
title('加入单频干扰的原始信号');
subplot(4,1,3);
plot(t,e);
title('自适应陷波器输出');
axis([0 400 -1 1]);
subplot(4,1,4);
plot(t,s-e);
title('信号误差');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -