PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

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

(^0500100015002000)
frequency in Hz
Frequency
2500 3000 3500 4000
(^05001000150020002500300035004000)
5
0
200
400
600
− 10
0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.03 5
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.

Free download pdf