作业帮 > 综合 > 作业

matlab程序语句功能求解,下面这短程序什么意思

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/17 07:40:51
matlab程序语句功能求解,下面这短程序什么意思
clc;
clear;
ref =wavread('in.wav'); % Load near end
apm = 0.1; %噪声幅度
firLen = 160;
mu = 0.8;
a = zeros(1,firLen);
dataLen = length(ref);
eout = zeros(1,dataLen);
bbeout = zeros(1,dataLen);
firIn = zeros(1,firLen);
firIntwo = zeros(1,firLen);
noise = apm*rand(1,dataLen);
near = ref'+noise;
%%%自适应滤波学习bbe模型
for i=1:dataLen
for j = firLen-1:-1:1
firIn(j+1) = firIn(j);
end
firIn(1) = noise(i);
firOut = a*firIn'; %fir滤波
e = near(i)-firOut; %求误差信号
a = a+e*mu*firIn; %lms 系数更新
eout(i) = e;
end
wavwrite(eout,16000,'out.wav');
figure(1)
subplot(411);
plot(ref);
title('原始信号');
subplot(412);
plot(near);
title('语音加噪信号');
subplot(413);
plot(noise);
title('噪声信号');
subplot(414);
plot(eout);
title('自适应消噪信号');
我知道这是一个LMS自适应滤波的降噪程序,但是中间的细节都不是很清楚什么意思
麻烦大神们在后面每一句加上注释,各个函数和参数分别是什么意思 我是小白 麻烦写明白点
还有就是 apm=0.1 是噪声幅度
firLen = 160;
mu = 0.8;
a = zeros(1,firLen);分别是什么意思?
firLen = 160;定义了滤波器的长度
mu = 0.8;定义了学习因子的大小,也是自适应算法的迭代步长
a = zeros(1,firLen);这句产生了一个1行160列的零向量.
clc;
clear;
% ref =wavread('in.wav'); % Load near end
ref = wgn(1,1024,0).'; % 我加了这句,因为我没有你的音频文件,不妨碍功能验证和你对程序原理的理解
apm = 0.1; %噪声幅度
firLen = 160; % 定义了滤波器的长度
mu = 0.8; % 学习因子
a = zeros(1,firLen);
dataLen = length(ref); % 获取了ref信号向量的长度
eout = zeros(1,dataLen); % 产生1行dataLen列的行向量
bbeout = zeros(1,dataLen); % 同上
firIn = zeros(1,firLen); % 同a
firIntwo = zeros(1,firLen); % 同上
noise = apm*rand(1,dataLen); % 产生随机噪声,用来干扰语音信号,实际上我这里也用噪声作为语音信号
near = ref'+noise; % 产生含加性噪声的语音信号,表示语音信号被噪声污染了
%%%自适应滤波学习bbe模型
for i=1:dataLen
for j = firLen-1:-1:1
firIn(j+1) = firIn(j);
end % 这个for循环让firIn向量的后一个值等于前一个值
firIn(1) = noise(i); % 第一个值等于噪声
firOut = a*firIn'; %fir滤波 这一步实现的是横向滤波器的操作
e = near(i)-firOut; %求误差信号
a = a+e*mu*firIn; %lms 系数更新
eout(i) = e;
end
% wavwrite(eout,16000,'out.wav');
figure(1)
subplot(411);
plot(ref);
title('原始信号');
subplot(412);
plot(near);
title('语音加噪信号');
subplot(413);
plot(noise);
title('噪声信号');
subplot(414);
plot(eout);
title('自适应消噪信号');
figure;plot(abs(ref.' - eout))
最后一句是我加上的,想看看你的程序去噪能力怎么样,你也可以自己看看,我觉得你的程序算法那块怪怪的,你在确认下算法有没有问题
再问: 真的很厉害 十分感谢 这个程序能运行 至于您说的怪怪的我不懂怎么回事 具体课题是语音信号加入一个外界的随机噪声,然后利用LMS自适应滤波去噪 对于这个程序我还有一个问题,就是中间LMS滤波器算法应该以一个什么标志作为结束呢? 我问的导师大概意思说是方差小于一定值,也就是噪声趋于稳定之类的我没听懂 能否再讲解一下?