532
Practical MATLAB
® Applications for Engineers
xlabel(‘frequency in Hz’)
disp(‘*******************************************************************’)
disp(‘********************** R E S U L T S ****************************’)
fprintf(‘For a shift of:%f\n’,shift);
error _ mag _ DFT= sum(abs(DFT _ fn)-abs(DFT _ fn _ shift));
error _ phase _ DFT=sum(angle(DFT _ fn)-angle(DFT _ fn _ shift));
fprintf(‘Cumulative magnitude of the error in the frequency
domain:%f\n’,error _ mag _ DFT);
fprintf(‘Cumulative phase error in the frequency
domain:%f\n’,error _ phase _ DFT);
disp(‘*******************************************************************’)
The script fi le shift is executed, and the results are as follows:
>> shift
*************************************************************************
************************** R E S U L T S *******************************
For a shift of: 32.000000
Cumulative magnitude of the error in the frequency domain:-2245.168919
Cumulative phase error in the frequency domain:3.141593
*************************************************************************
Time
0
500
1000
1500
2000
frequency in Hz
Frequency
2500
3000
3500
4000
0
500
1000
1500
2000
2500
3000
3500
4000
5
0
200
400
600
−10
0
0
0.005
0.01
0.015
0.02
0.025
0.03
0.035
10
0
angle [DFT[f(n)]]
abs [DFT[f(n)]]
Magnitude
−5
f(n)=7cos(2.pi.1000.n)*window, analyzed in the time and frequency domains
FIGURE 5.44
Plots of f(n) in time and frequency of Example 5.10.
CRC_47760_CH005.indd 532
CRC_47760_CH005.indd 532
7/23/2008 1:47:36 PM
7/23/2008 1:47:36 PM
Practical MATLAB
® Applications for Engineers
xlabel(‘frequency in Hz’)
disp(‘*******************************************************************’)
disp(‘********************** R E S U L T S ****************************’)
fprintf(‘For a shift of:%f\n’,shift);
error _ mag _ DFT= sum(abs(DFT _ fn)-abs(DFT _ fn _ shift));
error _ phase _ DFT=sum(angle(DFT _ fn)-angle(DFT _ fn _ shift));
fprintf(‘Cumulative magnitude of the error in the frequency
domain:%f\n’,error _ mag _ DFT);
fprintf(‘Cumulative phase error in the frequency
domain:%f\n’,error _ phase _ DFT);
disp(‘*******************************************************************’)
The script fi le shift is executed, and the results are as follows:
>> shift
*************************************************************************
************************** R E S U L T S *******************************
For a shift of: 32.000000
Cumulative magnitude of the error in the frequency domain:-2245.168919
Cumulative phase error in the frequency domain:3.141593
*************************************************************************
Time
0
500
1000
1500
2000
frequency in Hz
Frequency
2500
3000
3500
4000
0
500
1000
1500
2000
2500
3000
3500
4000
5
0
200
400
600
−10
0
0
0.005
0.01
0.015
0.02
0.025
0.03
0.035
10
0
angle [DFT[f(n)]]
abs [DFT[f(n)]]
Magnitude
−5
f(n)=7cos(2.pi.1000.n)*window, analyzed in the time and frequency domains
FIGURE 5.44
Plots of f(n) in time and frequency of Example 5.10.
CRC_47760_CH005.indd 532
CRC_47760_CH005.indd 532
7/23/2008 1:47:36 PM
7/23/2008 1:47:36 PM
