Digital Signal Processing Reference
In-Depth Information
2
1.5
1
0.5
0
0
10
20
30
40
50
60
70
80
Frequency (KHz)
2
1.5
1
0.5
0
0
10
20
30
40
50
60
70
80
Frequency (KHz)
FIGURE 12.12
(Top) The spectrum after upsampling, and (bottom) the spectrum after applying the interpolation filter.
N
¼
2048;
% Number of samples
L
4;
fsL
¼
fs*L; % Upsampling rate
%Upsampling filter (see Chapter 7 for FIR filter design)
Bup
¼
¼
firwd(97,1,2*19025*pi/fsL,0,4);
n
¼
0:1:N-1;
% Generate the time indices
x
¼
5*sin(2*pi*16000*n*T);
% Generate the test signal
% Upsampling by a factor of L
w
¼
zeros(1,L*N);
for n
¼
0:1:N-1
w(L*n
þ
1)
¼
x(n
þ
1);
end
NL
¼
length(w); % Number of the upsampled data
W
¼
2*abs(fft(w,NL))/NL;W(1)
¼
W(1)/2; % Compute the one-sided
% amplitude spectrum
f
¼
[0:1:NL/2-1]*fs*L/NL;
% Map the frequency index to its frequency in Hz
f
¼
f/1000;
% Convert to kHz
% Interpolation
y
¼
filter(Bup,1,w); % Perform the interpolation filter
Y
¼
2*abs(fft(y,NL))/NL;Y(1)
¼
Y(1)/2; % Compute the one-sided
% amplitude spectrum
Search WWH ::
Custom Search