M = length(x);
y = zeros(1,M);
h = zeros(1,N);
e = zeros(1,M);
for k = 1:fix(M/N) - 1
procx = fft(x((k - 1)*N + 1: (k + 1)*N));
H = fft([h,zeros(1,N)]);
prcox1 = real(ifft(procx.*H));
y(k*N + 1: (k + 1)*N) = prcox1(N + 1:2*N);
e(k*N + 1: (k + 1)*N) = d(k*N + 1: (k + 1)*N) - y(k*N + 1: (k + 1)*N);
E = fft([zeros(1,N),e(k*N + 1: (k + 1)*N)]);
prcox2 = real(ifft(E.*conj(procx)));
v = prcox2(1:N);
h = h + 2*u*v;
end
使用脚本程序如下:
clear
close all
clc
dbstop if error
s = sin(0:0.1:100);
b = fir1(32,0.3);%生成fir滤波器
x = awgn(s,5);%加白噪声
d = filter(b,1,s);%实际应用中的期望信号
u = 0.001;
N = 32;
[fh,fy,fe] = flmsFunc(x,d,u,N);%lms滤波
[th,ty,te] = lmsFunc(x,d,u,N);%flms滤波
subplot(3,1,1)
plot(x,'-k')
box on
title('原始信号')
axis tight
subplot(3,1,2)
plot(d,'-g')
box on
title('期望信号')
axis tight
subplot(3,1,3)
hold on
plot(ty,'-r')
plot(fy,'-g')
box on
legend('lms滤波信号','flms滤波信号')
title('lms与flms去噪信号')
hold off
axis tight