You can build AOs from existing ASCII data files. Various formats are supported, for example, multiple columns, files containing comments.


Install the data pack


The data-pack for this training session should be downloaded from the LTPDA web-site. The zip file will expand to a top-level directory. This should contain sub-directories for each topic of the training session.

The rest of the tutorial will assume that you have changed directories in MATLAB to the data-pack directory so that filenames are relative to that directory. To change the working directory of MATLAB, either use the MATLAB interface or type

  cd /path/to/my/data/pack

Create an AO from a simple ASCII file


The data-pack contains a simple two-column text file which represents a time-series sampled at 10Hz. The first column contains the time-stamps, the second column the amplitude values.

To convert this data file to an AO, use the following command:

>> a = ao('topic1/simpleASCII.txt')
M: running ao/ao
M:   load file: simpleASCII.txt
M:   constructing from filename and/or plist
M: running ao/ao
M:   constructing from data object tsdata
M: running ao/ao
M: running ao/display
----------- ao 01: topic1/simpleASCII.txt_01_02 -----------
 
       name:  topic1/simpleASCII.txt_01_02
description:  
       data: (0,0.454992359600435) (0.1,0.307272609435985) (0.2,0.691315196578838) (0.3,-0.713845553902851) (0.4,0.0136718022334676) ...
             -------- tsdata 01 ------------
              
                 fs:  10
                  x:  [1000 1], double
                  y:  [1000 1], double
             xunits:  [s]
             yunits:  []
              nsecs:  100
                 t0:  1970-01-01 00:00:00.000
             -------------------------------
              
       hist:  ao / ao / $Id: ltpda_training_topic_1_6_content.html,v 1.1 2009/02/05 14:32:18 hewitson Exp $-->$Id: ltpda_training_topic_1_6_content.html,v 1.1 2009/02/05 14:32:18 hewitson Exp $
  mfilename:  
mdlfilename:  
-----------------------------------------------------------

From the output on the screen you can see that

  • the name of the AO has automatically been set based on the filename and the columns of data loaded
  • the sample rate of the data is 10Hz, as expected
  • the length of the data is 100s
  • You can plot this data and see that it is just a randon noise time-series.


    Create an AO from a multi-column ASCII file


    The data-pack contains a data file which contains multiple columns of data. Here we will load only selected columns from the file and produce multiple AOs, one for each column loaded. Column 1 of the file contains the time-stamps; columns 2-6 contain sine waves at frequencies 1-5Hz.

    Let's load the 2Hz and 4Hz sine waves from the file. At the same time, we'll give the AOs names, Y units, and descriptions.

                    sigs = ao(plist('filename', 'topic1/multicolumnASCII.txt', ...
                    'columns', [1 3 1 5], ...
                    'name', {'sin2', 'sin4'}, ...
                    'yunits', {'m', 'm'}, ...
                    'description', {'sine wave at 2Hz', 'sine wave at 4Hz'}))  
    

    You can plot the results and focus on the first 2 seconds of data

        sigs.iplot(plist('XRanges', [0 2]))