fg_08_17.m

来自「英文书《Digital Signal Processing with Examp」· M 代码 · 共 43 行

M
43
字号
% fg_08_17          Noise cancellation - signals & spectra.
K=40000; T=1/40000;
% Copy the speech signal.
fid=fopen(['signal_3.txt']);
s=fscanf(fid,'%7d%8d%8d%8d%8d%8d%8d%8d%8d%8d\n',K);
fclose(fid);
s=127*s'/max(abs(s));
% Generate the rock drill noise.
b=[1 zeros(1,99) -.99];
a=[1 -2*.99*cos(2*pi*2/100) .99^2];
randn('seed',0);
noise=filter(b,a,10*rand(1,40000));

% Plot the signals and spectra.
sp_fig(1,9,5.5);
subplot(2,2,1);
set(gca,'fontsize',16);
line([0:K-1]*T,s,'color','r'); grid on;
axis([0 1 -150 150]);
xlabel('t (s)'); ylabel('s(t)');

subplot(2,2,2);
set(gca,'fontsize',16);
line([0:K-1]*T,noise,'color','b'); grid on;
axis([0 1 -500 500]);
xlabel('t (s)'); ylabel('n(t)');

subplot(2,2,3);
P=pds(s,s,400,5,.5);
dB=10*log10(max(-100,P(1:201)));
set(gca,'fontsize',16);
line(linspace(0,20,201),dB,'color','r'); grid on;
axis([0 20 -20 60]);
xlabel('Frequency (KHz)'); ylabel('Signal power (dB)');

subplot(2,2,4);
P=pds(noise,noise,400,5,.5);
dB=10*log10(max(-100,P(1:201)));
set(gca,'fontsize',16);
line(linspace(0,20,201),dB,'color','b'); grid on;
axis([0 20 -20 60]);
xlabel('Frequency (KHz)'); ylabel('Noise power (dB)');

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?