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

📄 chenxu (2).txt

📁 一个用自适应维纳FIR滤波器消除脑电波中的干扰
💻 TXT
字号:

我编了一个用自适应维纳FIR滤波器消除脑电波中的干扰
你们看看,这是我毕社的一个程序




clear
clc

n=0:1:100; %采样点数 

N=5; %FIR 滤波器的阶数

n1=sin(n*pi/3); % 60HZ的噪声源
n2=0.5*sin(n*pi/3+rand*pi);%经噪声路径滤波器后的噪声

x1=rand(1,length(n));%-0.2—+0.2随机信号的产生
x=2*(x1-0.5)/5;

y=x+n2; %混杂的信号
g=length(y);

H=zeros(N,g); 
T1=zeros(1,N);

u=1/(norm(n1*n1')); %调整系数

e=zeros(1,g); %存放滤波后信号初始的向量

for k=1:g %处理信号 
for i=1:N-1
T1(i)=T1(i+1);
end
T1(N)=n1(k);
y1(k)=T1*H(:,k);
e(k)=y(k)-y1(k);
H(:,k+1)=H(:,k)+2*u*e(k)*T1';

end

N1=100;
figure(1)
subplot(2,1,1)
plot(y)
axis([ 1 N1 -0.7 0.7])
axis auto'x'
title('干扰后的信号')
subplot(2,1,2)
plot(e)

axis([ 1 N1-1 -0.7 0.7])
axis auto'x'
hold on
subplot(2,1,2)
plot(x,'r')
title('滤波后的信号与原始信号对比')
axis([1 N1-1 -0.7 0.7])
axis auto'x'
figure(2)

plot(H(1,')
title('一个权系数收敛情况') 

clear
clc

n=0:1:100; %采样点数 

N=5; %FIR 滤波器的阶数

n1=sin(n*pi/3); % 60HZ的噪声源
n2=0.5*sin(n*pi/3+rand*pi);%经噪声路径滤波器后的噪声

x1=rand(1,length(n));%-0.2—+0.2随机信号的产生
x=2*(x1-0.5)/5;

y=x+n2; %混杂的信号
g=length(y);

H=zeros(N,g); 
T1=zeros(1,N);

u=1/(norm(n1*n1')); %调整系数

e=zeros(1,g); %存放滤波后信号初始的向量

for k=1:g %处理信号 
for i=1:N-1
T1(i)=T1(i+1);
end
T1(N)=n1(k);
y1(k)=T1*H(:,k);
e(k)=y(k)-y1(k);
H(:,k+1)=H(:,k)+2*u*e(k)*T1';

end

N1=100;
figure(1)

subplot(2,1,1)
plot(y)

axis([ 1 N1 -0.7 0.7])
axis auto'x'
%title('滤波后信号与原始信号.前面.的对比')
title('干扰后的信号')
%hold on
%plot(t1(2,:),'r')

%axis([ 1 N1 -0.7 0.7])
%axis auto'x'

subplot(2,1,2)
plot(e)
%plot(t1(3,:),'b')
%title('滤波后的信号')
axis([ 1 N1-1 -0.7 0.7])
axis auto'x'

hold on
subplot(2,1,2)
plot(x,'r')
title('滤波后的信号与原始信号对比')
axis([1 N1-1 -0.7 0.7])
axis auto'x'

%figure(2)

%hold on
%plot(t1(4,:),'r')
%title('滤波后信号与原始信号.后面.的对比')
figure(2)
%plot(nk1)
%subplot(2,1,2)
plot(H(1,:)')
title('一个权系数收敛情况')  

⌨️ 快捷键说明

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