资源简介
参考信号为宽带与窄带信号,利用FxLMS算法进行控制,可作为参考程序进行修改。demo1。
代码片段和文件信息
% ANC of the primary noise with both broadband signal and narrowband signal
Fs=8000; %Sampling frequency
% Design the Secondary Path TF
Fd=fdesign.lowpass(‘NF3db‘220.4);
Hd=design(Fd‘Fir‘);
% Hd.Numerator=Hd.Numerator/norm(Hd.Numerator);
% Estimaiting the Secondary Path TF
ntrS=10000; s=randn(1ntrS);
dS=filter(Hd.Numerator1s)+sqrt(0.1)*randn(1ntrS);
M=31; muS=0.01;
lms=dsp.LMSFilter(‘StepSize‘‘M‘‘StepSizeSource‘‘Input port‘);
[y errw] = lms(s‘dS‘muS);
% Design the Primary Path TF
Fd2=fdesign.lowpass(‘NF3db‘420.4);
Hd2=design(Fd2‘FIR‘);
% The noise to be cancelled
ntrW=30000; n=1:ntrW;
% Sine components angular frequencise and DFCs
wsin=[0.03 0.06 0.09];
ar=[2 1 0.5];
br=[-1 -0.5 0.1];
% Generate the narrowband component
narrow=zeros(1ntrW);
for k=1:length(wsin)
narrow=narrow+ar(k)*cos(pi*wsin(k)*n)+br(k)*sin(pi*wsin(k)*n);
end
% Wideband component with variance 1
wide=randn(1ntrW);
white=1; % Leave the wideband noise white
if white~=1
Fdbp=fdesign.bandpass(0.010.050.150.2560160);
Hdbp=design(Fdbp‘equiripple‘);
wide=filter(Hdbpwide);
wide=wide/sqrt(var(wide));
end
x=narrow+wide;
% Filter the primary noise through the primary path TF and additional noise
% with variance 0.1;
d=filter(Hd2.Numerator1x)+sqrt(0.1)*randn(1ntrW);
% Calculate the PSD for the plot
Hp=spectrum.welch;
Hp.SegmentLength=4444;
Pd=psd(Hpd(ntrW-10000:ntrW)‘NFFT‘8192‘Fs‘Fs);
% Active noise control using the FxLMS a
评论
共有 条评论