【问题标题】:Coding noise cancellation in matlab在matlab中编码噪声消除
【发布时间】:2019-09-29 10:20:40
【问题描述】:

这是我在网上找到的一个程序。它应该从文件夹中获取音频文件,添加噪音然后将其过滤掉。然而,ha=dsp.LMSFilter(256,mu);是错误的,如何将正确的参数添加到 dsp.LMSFilter(),我不知道。阿洛斯,我不明白代码的工作原理。任何帮助,将不胜感激。这是我大学里一个非常重要的分级项目的一部分。

load handel.mat;
d= 'Recording.m4a';
samples = [1,20*Fs];
clear d Fs
[d,Fs] = audioread('Recording.m4a',samples);
sound(d,Fs)
pause(3)
x=awgn(d,20);
sound(x,Fs) 
pause(3)
mu=0.017;%stepsize
ha=dsp.LMSFilter(256,mu); 
[y,e]=filter(ha,x(:,1),d(:,1));
sound(y,Fs)
subplot(4,1,1),plot(d)
grid on
xlabel('iterations')
ylabel('amplitude')
title('original voice signal')
subplot(4,1,2)
plot(x)
grid on
xlabel('iterations')
ylabel('amplitude')
title('signal with AWGN')
subplot(4,1,3)
plot(y)
grid on
title('filtered output')
xlabel('iterations')
ylabel('amplitude')
subplot(4,1,4)
plot(e)
grid on
title('error signal')
xlabel('iterations')
ylabel('amplitude')

【问题讨论】:

  • 如果这是您教育的重要评分作业的一部分,最好祈祷教授不属于 SO。
  • 或许阅读docs 会有所帮助。
  • "这是我在网上找到的一个程序。"请为您在 Stack Overflow 上发布的任何代码提供正确的署名,就像您提交项目进行评分一样。 (你打算这样做,对吧?)
  • 是的,我是。对不起,我没有意识到。会一直这样做...
  • 这是原论文:google.com/…

标签: matlab noise cancellation


【解决方案1】:

我尝试了您的代码并收到此错误。

  Error using
  matlab.system.SystemProp/parseInputs
  dsp.LMSFilter System object constructor
  supports only 1 value-only inputs. You have
  specified 2 value-only inputs. A common cause
  of this error is misspelling a property name.

  Error in
  matlab.system.SystemProp/setProperties

  Error in dsp.LMSFilter

  Error in SO (line 12)
  ha=dsp.LMSFilter(256,mu);

这意味着您在 LMSFilter 函数中提供了一个额外的参数。 而您复制的来自互联网的代码可能是这样的

 ha=adaptfilt.lms(256,mu);

这里的adapfilt可能有接受2个参数的lms函数

【讨论】:

  • 是的,这是我得到的错误。最初,代码使用了 adaptfilt.lms()。但是,当我运行原始代码时,它说新版本的 MATLAB 不再支持 adaptfilt.lms(),并且有人建议我使用 dsp.LMSFilter()。问题是,我不知道如何给出正确的参数...
  • 我已经检查过那篇论文,这就是为什么在之前的答案中建议使用一个参数的原因。看看你是否想使用 dsp.LMSFilter() 那么你只需要提供一个参数,比如 ha= dsp.LMSFilter(mu);但是如果你想提供两个参数,那么你需要使用其他过滤器,比如 adaptfilt.lms(256,mu)。我希望这会有所帮助。
猜你喜欢
  • 2017-04-14
  • 2011-10-15
  • 1970-01-01
  • 1970-01-01
  • 2013-08-01
  • 2016-06-13
  • 2013-03-14
  • 1970-01-01
  • 2012-09-18
相关资源
最近更新 更多