Page 96 - MATLAB Recipes for Earth Sciences
P. 96

5.2 Generating Signals                                           89

           The period of τ=5 corresponds to a frequency of f=1/5=0.2. Natural data
           series, however, are much more complex than a simple period signal. The
           next complicated signal is generated by superposition of several periodic
           components with different periods. As an example, we compute such a
           signal by adding three sine waves with the periods τ =50 (f =0.02), τ =15
                                                           1     1       2
           (f §0.07) and τ =5 (f =0.2), respectively. The corresponding amplitudes are
             2          3    3
           A =2, A =1 and A =0.5. The new time axis t runs from 1 to 1000 with 1.0
             1    2        3
           intervals.
             t = 1 : 1000;
             y = 2*sin(2*pi*t/50) + sin(2*pi*t/15) + 0.5*sin(2*pi*t/5);

             plot(t,y),axis([0 200 -4 4])

           Only one fifth of the original data series is displayed by restricting the x-axis

           limits to the interval [0 200]. It is, however, recommended to generate long
           data series as in the example in order to avoid edge effects while applying
           spectral analysis tools for the fi rst time.
             In contrast to our synthetic time series, real data also contain various dis-
           turbances, such as random noise and first or higher-order trend. Firstly, a

           random-number generator can be used to compute gaussian noise with zero
           mean and standard deviation one. The seed of the algorithm needs to be set
           to zero. Subsequently, one thousand random numbers are generated using
           the function randn.
             randn('seed',0)
             n = randn(1,1000);
           We add this noise to the original data, i.e., we generate a signal containing
           additive noise (Fig. 5.3). Displaying the data illustrates the impact of noise
           on a periodic signal. In reality, no record that is free of noise. Hence, it is im-

           portant to familiarize oneself with the influence of noise on power spectra.
             yn = y + n;

             plot(t,y,'b-',t,yn,'r-'), axis([0 200 -4 4])
           In many cases, the signal processing methods are applied to remove most of

           the noise although many filtering methods make arbitrary assumptions on

           the signal-to-noise ratio. Moreover, filtering introduces artifacts and statisti-
           cal dependencies to the data. These may have a profound influence on the

           resulting power spectra.
             Finally, we introduce a linear long-term trend to the data by adding a
           straight line with slope 0.005 and intercept zero with the y-axis (Fig. 5.3).
   91   92   93   94   95   96   97   98   99   100   101