clc;
clear;
close all;
warning off;
addpath(genpath(pwd));
mus = [0.01 0.05 0.1 0.5 1 2 2.5 3];% 0.5 1];
for j = 1:length(mus)
for i = 1:100
%%INITIALIZE VALUES%%
% generate input signal
muOG=mus(j); %learning rate
M=128; %buffer size (num filter weights)
x=randn(10000,1); %input signal
x=x/max(x); %sample rate
fs=8000; %number of samples of the input signal
N=length(x); %length of input signal
% generate known filter coefficients
Pz=0.5*[0:127]; %linear coefficients
%Pz=randn(128,1); %random coefficients
ylim = max(Pz)*1.20;
ymin = min(Pz)-.2*max(Pz);
% generate filtered input signal == desired signal
d=conv(Pz,x); %input signal filtered by known filter Pz (primary path)
Sz = Pz/2;
%run known signal through filter
xp=conv(Sz,x);
%initalize Sz hat values
Szh=zeros(M,1);
for n=M:N
xpvec=x(n:-1:n-M+1); %input has to be in reverse orxer has to be
%update mu
mu(n) = 1/(xpvec'*xpvec);
e(n)=xp(n)-Szh'*xpvec; %update error
%plot(e)
Szh=Szh+mu(n)*xpvec*(e(n)); %update filter coefficient
end
Szh = abs(ifft(1./abs(fft(Szh))));
emean=zeros(N,1);
%filter input by learned filter to get x prime
xph = conv(Szh,x);
%initalize Wz filter values
Wz=zeros(M,1);
%Make sure that x and d are column vectors
x=x(:);
d=d(:);
%LMS
for n=M:N
xvec=x(n:-1:n-M+1); %input has to be in reverse orxer
xpvec=xph(n:-1:n-M+1);
%update mu
mu(n) = muOG/(xvec'*xvec);
e(n)=d(n)-Wz'*xvec; %update error
%plot(e)
Wz=Wz+mu(n)*xpvec*(e(n)); %update filter coefficient
end
e=e(:);
emean = (emean(:)+e);
end
emean=(emean)/i;
if max(emean)>1e4
for l = 1:length(emean)
if abs(emean(l)) > 1e3
emean(l)=1e3;
end
end
eall(j,:)=emean;
else
try
[eall(j,:),q]=(envelope(abs(emean),500,'peaks'));
catch
eall(j,:) = 1e3;
end
end
end
figure
for i = 1:length(mus)
plot(10*log10(abs(eall(i,:))))
hold on
end
title('Convergence Time in Cycles')
ylabel('Error (dB)');
xlabel('Cycles');
legend('0.01','0.05','0.1','0.5','1.0', '2.0');
对比NLMS,FxLMS以及FxNLMS三种自适应滤波matlab仿真+仿真录像
版权申诉
5星 · 超过95%的资源 122 浏览量
2022-10-29
04:26:14
上传
评论
收藏 3.91MB RAR 举报
fpga和matlab
- 粉丝: 16w+
- 资源: 2561
最新资源
- 简单的Python示例,演示了如何使用TCP/IP协议进行基本的客户端和服务器通信
- 考试.sql
- keil2 + proteus + 8051.exe
- 1961ee27df03bd4595d28e24b00dde4e_744c805f7e4fb4d40fa3f695bfbab035_8(1).c
- mediapipe-0.9.0.1-cp37-cp37m-win-amd64.whl.zip
- windows注册表编辑工具
- mediapipe-0.9.0.1-cp37-cp37m-win-amd64.whl.zip
- 校园通行码预约管理系统20240522075502
- 车类型数据集6250张VOC+YOLO格式.zip
- The PyTorch implementation of STGCN.STGCN-main.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈