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

📄 lmssuanfaxianbo5chuanxing.m

📁 自适应陷波算法
💻 M
字号:
%自适应陷波滤波器
%自适应陷波器仿真
clear all
clc
N=2000;                         %总采样长度
t=0:N-1;                       
s=sin(2*pi*t/20);              %原始正弦信号
A=5;                         %干扰信号的幅值
fai=pi/3;                      %干扰信号的相移
n1=A*cos(2*pi*t/10+fai);        
n2=A*cos(2*pi*t/15+fai*2);          %干扰信号
x=s+n1+n2;                        %引入正弦单频干扰的原始输入
x1=cos(2*pi*t/10);                 %参考输入1
x2=sin(2*pi*t/10);                 %参考输入2
x3=cos(2*pi*t/15);                 %参考输入3
x4=sin(2*pi*t/15);                 %参考输入4
w1=20;
w2=20; 
w3=20;
w4=20;                            %权矢量初值
e1=zeros(1,N);
e2=zeros(1,N);
y1=0;
y2=0;
u=0.05;                  
for i=1:N                          %LMS算法
    y1=w1*x1(i)+w2*x2(i); 
    e1(i)=x(i)-y1;
    w1=w1+u*e1(i)*x1(i);  
    w2=w2+u*e1(i)*x2(i); 
    y2=w3*x3(i)+w4*x4(i);
    e2(i)=e1(i)-y2;
    w3=w3+u*e2(i)*x3(i); 
    w4=w4+u*e2(i)*x4(i);  
end
X=x(500:2000);
E=e2(500:2000);
f1=abs(fft(X,1024));
f2=abs(fft(E,1024));
subplot(6,1,1);
plot(t,s);
title('原始正弦信号');
subplot(6,1,2); 
plot(t,x);
title('加入单频干扰的原始信号');
subplot(6,1,3);
plot(t,e2);
title('自适应陷波器输出');
axis([0 800 -1 1]);
subplot(6,1,4); 
plot(t,s-e2);
title('信号误差');
subplot(6,1,5);
plot(f1);
subplot(6,1,6);
plot(f2);

⌨️ 快捷键说明

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