PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

78 Practical MATLAB® Applications for Engineers


FIGURE 1.63
Plots of f(n), noise signal[n(t)], and [f(n) + n(t)] of Example 1.15.


Signal versus n

10

5

0

1

0

02468101214161820

− 1

0 2 4 6 8 101214 161820

Amplitude

Amplitude

Amplitude [signal+noise]

time index n

time index n

time index n

Noise versus n

10

5

0
0 2 4 6 8 10 12 14 16 18 20

[Signal+Noise] versus n

>> averages
********************************************************
*******************ANALYSIS OF ERROR*******************
********************************************************
no ave 2 term ave 3 term ave 4 term ave
0.5389 0.5276 0.7011 0.9793
********************************************************
********************************************************
>> averages
********************************************************
*******************ANALYSIS OF ERROR*******************
**************************************************
no ave 2 term ave 3 term ave 4 term ave
0.5272 0.4794 0.6574 0.9033
********************************************************
********************************************************
>> averages
********************************************************
*******************ANALYSIS OF ERROR*******************
**************************************************
no ave 2 term ave 3 term ave 4 term ave
0.4144 0.3750 0.5572 0.8223
********************************************************
********************************************************
Observe that the results obtained by executing the script fi le averages three times are not
the same, but in each case the best results are achieved when the moving average uses
two terms.
Free download pdf