Digital Signal Processing Reference
In-Depth Information
4
M=66
2
0
-2
-4
0
50
100
150
200
250
Number of samples
1.5
1
0.5
0
0
500
1000
1500
2000
2500
3000
3500
4000
Frequency (Hz)
FIGURE 7.23
The clean signal and spectrum with noise removed.
Program 7.7. MATLAB program for the application of noise filtering.
close all; clear all
fs
¼
8000;
% Sampling rate
T
¼
1/fs;
% Sampling period
v
¼
sqrt(0.1)*randn(1,250);
% Generate Gaussian random noise
n
¼
0:1:249;
% Indexes
x
¼
sqrt(2)*sin(2*pi*500*n*T)
þ
v;
% Generate 500-Hz plus noise
subplot(2,1,1);plot(n,x);
xlabel( ' Number of samples ' );ylabel( ' Sample value ' );grid;
N ¼ length(x);
f ¼ [0:N/2]*fs/N;
Axk ¼ 2*abs(fft(x))/N;Axk(1) ¼ Axk(1)/2;
% Calculate single side spectrum for x(n)
subplot(2,1,2); plot(f,Axk(1:N/2 þ 1));
xlabel( ' Frequency (Hz) ' ); ylabel( ' Amplitude
j X(f) j ' );grid;
figure
Wnc ¼ 2*pi*900/fs;
% Determine the normalized digital cutoff
frequency
B ¼ firwd(133,1,Wnc,0,4);
% Design FIR filter
y ¼ filter(B,1,x);
% Perform digital filtering
Ayk ¼ 2*abs(fft(y))/N;Ayk(1) ¼ Ayk(1)/2;
% Single-side spectrum of the filtered data
subplot(2,1,1); plot(n,y);
 
Search WWH ::




Custom Search