Page 110 - MATLAB Recipes for Earth Sciences
P. 110

5.5 Interpolating and Analyzing Unevenly-Spaced Data            103

             min(series2(:,1))
             max(series2(:,1))

           has a similar range from 0 to 997 kyrs. We see that both series have a mean
           spacing of 3 kyrs and range from 0 to ca. 1000 kyrs. We now interpolate the
           data to an evenly-spaced time axis. While doing this, we follow the rule that
           number of data points should not be increased. The new time axis runs from
           0 to 996 kyrs with 3 kyr intervals.
             t=0 : 3 : 996;

           We now interpolate the two time series to this axis with linear and spline
           interpolation methods.
             series1L = interp1(series1(:,1),series1(:,2),t,'linear');
             series1S = interp1(series1(:,1),series1(:,2),t,'spline');
             series2L = interp1(series2(:,1),series2(:,2),t,'linear');
             series2S = interp1(series2(:,1),series2(:,2),t,'spline');

           The results are compared by plotting the first series before and after inter-

           polation.
             plot(series1(:,1),series1(:,2),'ko')
             hold
             plot(t,series1L,'b-',t,series1S,'r-')


           We already observe some significant artifacts at ca. 370 kyrs. Whereas the
           linearly interpolated points are always within the range of the original data,
           the spline interpolation method produces values that are unrealistically high
           or low (Fig. 5.9). The results can be compared by plotting the second data
           series.
             plot(series2(:,1),series2(:,2),'ko')
             hold
             plot(t,series2L,'b-',t,series2S,'r-')
           In this series, only few artifacts can be observed. We can apply the function
           used above to calculate the power spectral density. We compute the FFT for
           256 data points, the sampling frequency is 1/3 kyrs .
                                                        -1
             [Pxx,f] = periodogram(series1L,[],256,1/3);
             magnitude = abs(Pxx);

             plot(f,magnitude);
             xlabel('Frequency')
             ylabel('Power')
             title('Power Spectral Density Estimate')
   105   106   107   108   109   110   111   112   113   114   115