lms.m

来自「用于心电信号滤波的LMS自适应噪声对消器设计」· M 代码 · 共 44 行

M
44
字号
%LMS噪声对消器设计算法 By Yao heng
clear all;
original=load('cm.txt');
mother=load('mother1024.txt');
original=original';
mother=mother';
M=1024;  %数据长度
N=2;     %滤波器阶数
mu=0.00004;       %步长
%初始化权系数
for i=1:N
    w(i)=0;
end      

%将mother信号右移N位,以便进行加权运算,mother1 = [zeros(1,N -1) mother];
for i=1:(N-1)
    mother1(i)=0;
end
for i=N:(N+M-1)
    mother1(i)=mother(i+1-N);
end

%调整滤波器系数的LMS算法
for n=1:M;
    %用移位后的参考信号迭代n次
   m=n+N-1;
   mother2=mother1(n:1:m)';   
   mother3(n)=w*(mother2);                %每次取N个参考信号与权系数相乘得到噪声估计	
   output(n)=original(n)-mother3(n);      %噪声抵消的输出
   w=w+mu.*mother2'.*output(n);           %权矢量迭代
end;
%输出波形
figure(1);
subplot(3,1,1);
plot(original);
title('混合心电信号');
subplot(3,1,2);
plot(mother);
title('母亲心电信号');
subplot(3,1,3)
plot(output);
title('滤波后的胎儿心电信号');
ylim([-100,100]);
xlim([0,1200]);

⌨️ 快捷键说明

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