LTPDA Toolbox™ | contents | ![]() ![]() |
You can build AOs from existing ASCII data files. Various formats are supported, for example, multiple columns, files containing comments.
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
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:
>> pl = plist('filename', 'topic1/simpleASCII.txt', ... 'columns', [1 2], ... 'type', 'tsdata'); >> a = ao(pl) M: constructing from plist M: load file: simpleASCII.txt M: constructing from filename and/or plist M: constructing from data object tsdata ----------- ao 01: simpleASCII.txt_01_02 ----------- name: simpleASCII.txt_01_02 data: (0,1.13549060238654) (0.1,2.37202031808076) (0.2,-0.531181753855465) (0.3,1.25684477541224) (0.4,1.30895517480354) ... -------- tsdata 01 ------------ fs: 10 x: [1000 1], double y: [1000 1], double dx: [0 0], double dy: [0 0], double xunits: [] yunits: [] nsecs: 100 t0: 1970-01-01 00:00:00.000 ------------------------------- hist: ao / ao / SId: fromDatafile.m,v 1.39 2011/04/18 16:55:26 ingo Exp S-->SId: ao.m,v 1.346 2011/05/07 06:56:17 mauro Exp S description: UUID: bde61c39-2c7e-4e77-9c15-6e6a4cc29e12 ----------------------------------------------------
From the output on the screen you can see that
You can plot this data and see that it is just a randon noise time-series.
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', ... 'type', 'tsdata', ... '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]))
![]() |
Saving and loading AOs | Writing LTPDA scripts | ![]() |
©LTP Team