📄 exp06_adaptive_notchfilter.m
字号:
5.自适应陷波器的仿真程序:
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;%信号混合
subplot(2,2,1);%作第一子图
plot(t,s);
subplot(2,2,2); %作第二子图
plot(t,x);
x1=cos(2*pi*t/10);
x2=sin(2*pi*t/10);
%初始化
%w1=0.1;
%w2=0.1;
%e=zeros(1,N);
%y=0;
%u=0.05;%迭代步长
%for i=1:N
%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(2,2,3); %作第三子图
%plot(t,e);
%subplot(2,2,4); %作第四子图
%plot(t,s-e);
w1=0.1;
w2=0.1;
e=zeros(1,N);
y=0;
u=0.05;%迭代步长
for i=1:N
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(2,2,3); %作第三子图
plot(t,e);
subplot(2,2,4); %作第四子图
plot(t,s-e);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -