| LTPDA Toolbox | contents | ![]() |
| Construct empty AO |
| Construct an AO by loading the AO from a file |
| Construct an AO from a data file |
| Construct an AO from a parameter list object (PLIST) |
| Construct from a set of values |
The following example creates an empty analysis object
>> a = ao
M: running ao/ao
M: empty constructor
M: running ao/display
----------- ao: a -----------
name: none
creator: created by hewitson@bobmac.aei.uni-hannover.de[130.75.117.65] on MACI/7.6 (R2008a)/1.9.1 beta (R2008a)
description:
data: None
hist: ao / ao / $Id: constructor_examples_ao_content.html,v 1.3 2008/08/22 15:33:51 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 determines how the analysis object is created. The valid key/value pairs 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 represents the x- and y-axes (each column pair creates an
analysis object). |
|
'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 represents the x- and y-axes.
% 'use_fs' is not used !!!
pl = plist('filename', 'data.dat', ...
'description', 'my ao description', ...
'type', 'xydata', ...
'xunits', 's', ...
'yunits', {'Volt', 'Hz'}, ...
'columns', [1 2 1 3], ...
'comment_char', '//');
out = ao('data.dat', pl);
out = ao(pl);
Another example where the time vector is specified by the sample rate (use_fs) and each column of data is converted in to a single AO.
% 'use_fs is used. As such, each column in col creates
its own AO with the specified sample rate.
pl = plist('filename', 'data.dat',...
'type', 'tsdata', ...
'use_fs', 100, ...
't0', {'14:00:00', '14:00:20', '14:00:30'}, ...
'columns', [1 2 3]);
out = ao('data.dat', pl);
out = ao(pl);
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 of type cdata (1D data).
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 of type tsdata (time-series data). The relevant parameters are:
|
'fs' |
sampling frequency [default: 10 Hz] |
|
'nsecs' |
length in seconds [default: 10 s] |
|
't0' |
Start time which is associated with the time-series [default: '1970-01-01 00:00:00.000'] |
pl = plist('fs', 10, 'nsecs', 10, ...
'tsfcn', 'sin(2*pi*1.4*t) + 0.1*randn(size(t))', ...
't0', '1980-12-01 12:43:12');
a1 = ao(pl)
Construct an AO from a function of frequency, f. The data object is of type fsdata (frequency-series). 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 |
pl1 = plist('fsfcn', '1./f.^2', 'scale', 'lin', 'nf', 100);
pl2 = plist('fsfcn', '1./f.^2', 'f', logspace(0,3, 1000));
a1 = ao(pl1)
a2 = ao(pl2)
Construct an AO from a spectral window object.
List of available window functions
pl1 = plist('win', specwin('Hanning', 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.
% Construct a sine wave
pl = plist('nsecs', 10, 'fs', 1000);
pl_w = pl.append('waveform', 'sine wave', 'phi', 30, 'f', 1.23);
out_sin = ao(pl_w)
% Construct random noise
pl_w = pl.append('waveform', 'noise', 'type', 'Normal');
out_noise1 = ao(pl_w)
% Construct uniform random noise
pl_w = append(pl, 'waveform', 'noise', 'type', 'Uniform');
out_noise2 = ao(pl_w)
% Construct a chirp waveform
pl_w = append(pl, 'waveform', 'chirp', 'f0', 1, 'f1', 50, 't1', 100);
out_chirp = ao(pl_w)
% Construct a Gaussian pulse waveform
pl_w = append(pl, 'waveform','Gaussian pulse', 'f0', 10, 'bw', 100);
out_gaus = ao(pl_w)
% Construct a Square wave
pl_w =append(pl,'waveform', 'Square wave', 'f', 1, 'duty', 50);
out_square = ao(pl_w)
% Construct a Sawtooth wave
pl_w = append(pl, 'waveform', 'Sawtooth', 'width', .5, 'f', 1);
out_saw = ao(pl_w)
Construct an AO from a set of polynomial coefficients. The relevant parameters are:
|
'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 MFIR class | ![]() |
©LTP Team