LTPDA Toolbox | contents | ![]() ![]() |
The following example creates an empty analysis object
a = ao() ----------- ao: a ----------- name: None provenance: created by diepholz@HWS169[127.0.1.1] on GLNXA64/7.5 description: data: None hist: history / ao / $Id: ao.m,v 1.97 2008/03/24 21:34:18 hewitson Exp mfilename: mdlfilename: -----------------------------
The following example creates a new analysis object by loading the analysis object from disk.
a = ao('a1.mat') a = ao('a1.xml')
The following example creates a new analysis object by loading the data in 'file.txt'. The ascii file is assumed to be an equally sampled two-column file of time and amplitude.
a = ao('file.txt') or a = ao('file.dat')
The following example creates a new analysis object by loading the data in 'file'. The parameter list decide how the analysis object is created. The valid key values of the parameter list are:
'type' |
'tsdata','fsdata','xydata' [default: 'tsdata'] |
'use_fs' |
If this value is set, the x-axes is computed by the fs value. [default: empty] |
'columns' |
[1 2 1 4] Each pair represented the x- and y-axes. (Each column pair creates an analysis object) |
'num_columns' |
Maximum colums in the file. Are there more columns in the file then set this value. [default: 10] |
'comment_char' |
The comment character in the file [default: '%'] |
'description' |
To set the description in the analysis object |
'...' |
Every property of the data object e.g. 'name' |
% Each pair in col represented the x- and y-axes. % 'use_fs' isnot used !!! fname = 'data.dat'; com = 'my ao description'; type = 'xydata'; xunits = 'SEC'; yunits = {'Volt', 'Hz'}; % Each AO get its own yunits col = [1 2 1 3]; pl = plist('filename', fname, ... 'description', com, ... 'type', type, ... 'xunits', xunits, ... 'yunits', yunits, ... 'columns', col, ... 'comment_char', '//'); out = ao('data.dat', pl); out = ao(pl);
% 'use_fs is used --> Each column in col creates with the frequency its own AO fname = 'data.dat'; type = 'tsdata'; fs = 100; t0 = time('14:00:00', ... 'HH:MM:SS'); col = [1 2 3]; pl = plist('filename', fname,... 'type', type, ... 'use_fs', fs, ... 't0', {t0, ... t0+20, ... t0+40}, ... 'columns', col); out = ao('data.dat', pl); out = ao(pl);
creates an analysis object with a data object. Data object can be one of tsdata, fsdata, cdata, xydata, xyzdata.
fs = 100; data1 = cdata([1 2 3; 4 5 6; 7 8 9]); data2 = fsdata(randn(1000,1), fs); data3 = tsdata(randn(1000,1), fs); data4 = xydata(randn(1000,1), randn(1000,1)); a1 = ao(data1); a2 = ao(data2); a3 = ao(data3); a4 = ao(data4);
Constructs an analysis object from the description given in the parameter list
Use the key word 'fcn' |
Use the key word 'tsfcn' |
Use the key word 'fsfcn' |
Use the key word 'win' |
Use the key word 'waveform' |
Use the key word 'polyval' |
The following example creates an AO from the description of any valid MATLAB function. The data object is from constant data (CDATA) class.
pl = plist('fcn', 'randn(100,1)'); a1 = ao(pl);
You can pass additional parameters to the fcn as extra parameters in the parameter list:
pl = plist('fcn', 'a*b', 'a', 2, 'b', 1:20); a1 = ao(pl);
Construct an AO from a function of time, t. The data object is from time-series (TSDATA) class.
'fs' |
sampling frequency [default: 10 Hz] |
'nsecs' |
length in seconds [default: 10 s] |
't0' |
Time object which is associated with the time-series [default: time(0)] |
pl = plist('fs', 10, 'nsecs', 10, ... 'tsfcn', 'sin(2*pi*1.4*t) + 0.1*randn(size(t))', ... 't0', time('1980-12-01 12:43:12')); a1 = ao(pl)
Construct an AO from a function of frequency, f. The data object is from frequency-series data (FSDATA) class. You can also specify optional parameters:
'f1' |
the initial frequency [default: 1e-9] |
'f2' |
the final frequency [default: 5] |
'nf' |
the number of frequency samples [default: 1000] |
'scale' |
'log' or 'lin' frequency spacing [default: 'log'] |
or provide a frequency vector:
'f' |
a vector of frequencies on which to evaluate the function |
f = logspace(0,3, 1000); pl1 = plist('fsfcn', '1./f.^2', 'scale', 'lin', 'nf', 100); pl2 = plist('fsfcn', '1./f.^2', 'f', f); a1 = ao(pl1) a2 = ao(pl2)
Construct an AO from a spectral window object.
List of available window functions
pl1 = plist('win', specwin('Hannning', 100)) pl2 = plist('win', specwin('Kaiser', 10, 150)); a1 = ao(pl1) a2 = ao(pl2)
Construct an AO from a waveform with the following waveform types
'sine wave' |
'A', 'f', 'phi' |
'noise' |
'type' (can be 'Normal' or 'Uniform') |
'chirp' |
'f0', 'f1', 't1' |
'Gaussian pulse' |
'f0', 'bw' |
'Square wave' |
'f', 'duty' |
'Sawtooth' |
'f', 'width' |
You can also specify additional parameters:
'fs' |
sampling frequency [default: 10 Hz] |
'nsecs' |
length in seconds [default: 10 s] |
You can also specify the initial time (t0) associated with the time-series by passing a parameter 't0' with a value that is a time object.
pl = plist('nsecs', 10, ... 'fs', 1000); pl_w = append(pl, 'waveform', ... 'sine wave', ... 'phi', 30, ... 'f', 1.23); out_sin = ao(pl_w) pl_w = append(pl, 'waveform', ... 'noise', ... 'type', ... 'Normal'); out_noise1 = ao(pl_w) pl_w = append(pl, 'waveform', ... 'noise', ... 'type', ... 'Uniform'); out_noise2 = ao(pl_w) pl_w = append(pl, 'waveform', ... 'chirp', ... 'f0', 1, ... 'f1', 50, ... 't1', 100); out_chirp = ao(pl_w) pl_w = append(pl, 'waveform', ... 'Gaussian pulse', ... 'f0', 10, ... 'bw', 100); out_gaus = ao(pl_w) pl_w =append(pl,'waveform', ... 'Square wave', ... 'f', 1, ... 'duty', 50); out_square = ao(pl_w) pl_w = append(pl, 'waveform', ... 'Sawtooth', ... 'width', .5, ... 'f', 1); out_saw = ao(pl_w)
'polyval' |
A set of polynomial coefficients. [default: [-0.0001 0.02 -1 -1] ] |
Additional parameters:
'nsecs' |
Number of seconds [default: 10] |
'fs' |
Sample rate[default: 10 s] |
or
't' |
vector of time vertices |
pl = plist('polyval', [1 2 3], 'Nsecs', 10, 'fs', 10); a1 = ao(pl)
The following example creates an AO from a set of values.
vals = [1 2 3; 4 5 6; 7 8 9];
pl = plist('vals', vals);
a1 = ao(vals)
a2 = ao(pl)
![]() |
Constructor Examples | Constructor examples of the CDATA class | ![]() |
©LTP Team