620 C H A P T E R 10: Fourier Analysis of Discrete-Time Signals and Systems
from 0 to 2π(N− 1 )/Nrad (notice that this value is close to 2πbut always smaller than 2πas
needed to display a period ofX[k]). We can change this scale into other frequency scales—for
instance, if we wish a scale that considers positive as well as negative frequencies, to the above
scale we subtractπ, and if we wish a normalized scale [−1 1), we simply divide the previous scale
byπ. When shifting to a [−π π)or [−1 1)frequency scale, the spectrum also needs to be shifted
accordingly—this is done using thefftshiftfunction. To understand this change recall thatX[k] is
also periodic of periodN.
The following script is used to compute the DFT ofx[n] andx[n+16] given above. The results are
shown in Figure 10.14.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Example 10.20---FFFT computation of causal and
% noncausal signals
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all; clf
N = 512; % order of the FFT
n = 0:N - 1;
% causal signal
x = [ones(1,33) zeros(1,N - 33)]; x = x.∗sin(pi∗n/32); % zero-padding
X = fft(x); X = fftshift(X); % fft and its shifting to [-1 1] frequency scale
w = 2∗[0:N - 1]./N - 1; % normalized frequencies
n1 = [-9:40]; % time scale
% noncausal signal
xnc = [zeros(1,3) x(1:33) zeros(1,3)]; % noncausal signal
x = [x(17:33) zeros(1,N-33) x(1:16)]; % periodic extension and zero-padding
X = fft(x); X = fftshift(X);
n1 = [-19:19]; % time scale n
nExample 10.21
Consider improving the frequency resolution of a periodic sampled signal
y(nTs)=4 cos( 2 πf 0 nTs)−cos( 2 πf 1 nTs) f 0 =100 Hz,f 1 = 4 f 0
where the sampling period isTs= 1 /( 3 f 1 )sec/sample.
Solution
In the case of a periodic signal, the frequency resolution of its FFT cannot be improved by attaching
zeros. The length of the FFT must be the period or a multiple of the period of the signal. The
following script illustrates how the FFT of the given periodic signal can be obtained by using 4 or
12 periods. As the number of periods increases the harmonic components appear in each case at
exactly the same frequencies, and only zeros in between these fixed harmonic frequencies result
from increasing the number of periods. However, the magnitude frequency response is increasing