Preparing data segments (splitting)

One of the most common tasks in data analysis is the preparing of the data segments to analyse. LTPDA offers various tools for preprocessing data. Here we will review the splitting of data segments using the ao/split method.

Suppose you have a segment of data and you want to split that up. Here are various examples showing how you might do that.

Split in to parts

To split the data in to N parts you can do:

      % Generate a time-series      
      waveformPlist = plist(...
                  'waveform', 'square wave', ...   % Generate a square wave
                  'f', 0.1, ...                    % with 0.1Hz frequency
                  'fs', 10, ...                    % sampled at 10Hz
                  'nsecs', 100, ...                % lasting for 100s
                  't0', '2012-03-10 12:00:00', ... % with the specified reference time
                  'toffset', 10 ...                % and the first sample starts 10s after the reference time
      a   = ao(waveformPlist);
      % Split into 5 parts      
      splitPlist1 = plist('N', 5);
      % Split the time-series      
      parts = split(a, splitPlist1);
      % Plot the result      

Split by time relative to t0

To split the data by elapsed time since the reference time t0 you can do

      % Split a segment starting a t=20 and finishing at t=75      
      splitPlist2 = plist('times', [20 75]);
      % Split the time-series      
      timeSegment = split(a, splitPlist2);
      % Plot the result      

Split by offsets

To split the data by an offset in seconds relative to the first and last samples, you do

      % Split a segment starting 10s from the start to 40s from the start      
      splitPlist3 = plist('offsets', [10 40]);
      % Split the time-series      
      offsetSegment = split(a, splitPlist3);
      % Plot the result      
You can also split relative to the end of the data by doing the following:
      % Make a segment which drops 10s from the beginning and end of the original      
      splitPlist4 = plist('offsets', [10 -10]);
      % Split the time-series      
      dropSegment = split(a, splitPlist4);
      % Plot the result      

Split by absolute time

To split the data by absolute times, you do

      % Split a segment starting and ending at particular times      
      splitPlist4 = plist('start_time', '2012-03-10 12:00:15', 'end_time', '2012-03-10 12:00:36');
      % Split the time-series      
      absTimeSegment = split(a, splitPlist4);
      % Plot the result      

©LTP Team