530 Practical MATLAB® Applications for Engineers
Example 5.10Let the audio analog signal f(t) be given byfttTs
tTst Ts
Ts t Ts()cos( )cos(0064
7 2 1000 64 128
0 128 192
7
22 1000 tTst Ts) 192 256
and sampling rate be Ts = 1/8000 samples/s.
Convert the continuous time function f(t) into a discrete sequence f(n).
Create the script fi le shift that uses the function f(n) to verify the property that states
that a shift in time only affects the phase spectrum and not the magnitude spectrum by
shifting f(n) by 32 time samples and return the following plots:
a. fi gure(1): f(n) versus n, abs{fft[f(n)]} versus f, and angle{fft[f(n)]} versus f (Figure 5.44)
b. fi gure(2): Repeat part a for f(n − 32) (Figure 5.45)
c. fi gure(3): [error in time = f(n) − f(n − 32)] versus t, [error_ mag = abs{fft[f(n)]} − abs{fft
[f(n − 32)]}] versus f, and [error_ phase = angle{fft[f(n)]} − angle{fft[f(n − 32)]}] versus
f (Figure 5.46)
d. Estimate the cumulative magnitude and phase errors in the frequency domain− 2 20− 2024681012141620024− 2− 2
468101214162002− 2468
frequency W in rad.10 12 14 16Error analysis in time and frequencyAmplitude in time[abs(DFTs)][angle(DFTs)]time index nW× 10 −^15× 10 −^15× 10 −^15FIGURE 5.43
Time and frequency error plots of Example 5.9.