| 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 spectral window |
| Construct an AO from a parameter list object (PLIST) |
The following example creates a copy of an 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.4 2009/02/25 19:11:56 ingo Exp $
mfilename:
mdlfilename:
-----------------------------
REMARK: The following command copies only the handle of an object and doesn't create a copy of the object (as above). This means that everything that happens to the copy or original happens to the other.
>> a1 = ao()
----------- ao 01: a1 -----------
name: none
description:
data: None
hist: ao / ao / $Id: constructor_examples_ao_content.html,v 1.4 2009/02/25 19:11:56 ingo Exp $
mfilename:
mdlfilename:
---------------------------------
>> a2 = a1;
>> a2.setName('my new name')
----------- ao 01: my new name -----------
name: my new name
description:
data: None
hist: ltpda_uoh / setName / $Id: constructor_examples_ao_content.html,v 1.4 2009/02/25 19:11:56 ingo Exp $
mfilename:
mdlfilename:
------------------------------------------
If we display a1 again then we see that the property 'name' was changed although we only have changed a2.
>> a1
----------- ao 01: my new name -----------
name: my new name
description:
data: None
hist: ltpda_uoh / setName / $Id: constructor_examples_ao_content.html,v 1.4 2009/02/25 19:11:56 ingo 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);
The following example creates a cdata type AO containing the window values.
win = specwin('Kaiser', 100, 10);
>> a = ao(win)
----------- ao 01: Kaiser -----------
name: Kaiser
description:
data: 0.7145 0.7249 0.7351 0.7452 0.7551 0.7649 0.7746 0.7840 0.7934 0.8025 ...
-------- cdata 01 ------------
y: [1x100], double
yunits: []
------------------------------
hist: ao / ao / $Id: constructor_examples_ao_content.html,v 1.4 2009/02/25 19:11:56 ingo Exp $-->$Id: constructor_examples_ao_content.html,v 1.4 2009/02/25 19:11:56 ingo Exp $
mfilename:
mdlfilename:
-------------------------------------
Constructs an analysis object from the description given in the parameter list.
The following example creates an AO from the description of any valid MATLAB function. The data object is of type cdata.
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);
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)
Construct an AO from a set of values. The data type depends on the parameters.
You have to specify the parameters:
|
'xvals' |
a set of x values. |
|
'yvals' |
a set of y values. |
You can also specify optional parameters
|
'dtype' |
type of the data object [default: tsdata] |
|
'fs' |
sampling frequency. Only used if 'dtype' is a time-series object [default: []] |
x = 1:1000;
y = randn(1000,1);
pl1 = plist('xvals', x, 'yvals', y, 'dtype', 'tsdata');
pl2 = plist('xvals', x, 'yvals', y, 'dtype', 'fsdata');
pl3 = plist('xvals', x, 'yvals', y, 'dtype', 'xydata');
a1 = ao(pl1) % Create an AO with time-series data
a2 = ao(pl2) % Create an AO with frequency-series data
a3 = ao(pl3) % Create an AO with x-y data
Construct an AO from a function of time, t. The data object is of type tsdata (time-series data).
|
'tsfcn' |
a function of time |
You can also specify optional parameters
|
'fs' |
sampling frequency [default: 1 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).
|
'fsfcn' |
a function of frequency |
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 function f(x) string. The data object is of type xydata.
You have to specify the parameters:
|
'xyfcn' |
specify a function of 'x' |
|
'x' |
the x values |
pl = plist('X', [1:50,52:2:100,110:10:1000], 'xyfcn', 'log(x)');
a1 = ao(pl)
----------- ao 01: a1 -----------
name: none
description:
data: (1,0) (2,0.693147180559945) (3,1.09861228866811) (4,1.38629436111989) (5,1.6094379124341) ...
-------- xydata 01 ------------
x: [1 165], double
y: [1 165], double
xunits: []
yunits: []
-------------------------------
hist: ao / ao / $Id: constructor_examples_ao_content.html,v 1.4 2009/02/25 19:11:56 ingo Exp $-->$Id: constructor_examples_ao_content.html,v 1.4 2009/02/25 19:11:56 ingo Exp $
mfilename:
mdlfilename:
---------------------------------
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' (help chirp) |
|
'Gaussian pulse' |
'f0', 'bw' (help gauspuls) |
|
'Square wave' |
'f', 'duty' (help square) |
|
'Sawtooth' |
'f', 'width' (help sawtooth) |
You can also specify additional parameters:
|
'fs' |
sampling frequency [default: 10 Hz] |
|
'nsecs' |
length in seconds [default: 10 s] |
|
't0' |
time-stamp of the first data sample [default time(0)] |
[default waveform: 'sine wave', A: 1, f: 1.23, phi: 0, fs: 10, nsecs: 10, t0: time(0) ].
% 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 by retrieving it from an LTPDA repository.
The relevant parameters are:
|
'hostname' |
the repository hostname. [default: 'localhost'] |
|
'database' |
The database name [default: 'ltpda'] |
|
'ID' |
A vector of object IDs. [default: []] |
|
'CID' |
Retrieve all AO objects from a particular collection. |
|
'Binary' |
Set to 'yes' to retrieve from stored binary representation (not always available). [default: yes] |
pl = plist('hostname', '130.75.117.67', 'database', 'ltpda_test', 'id', 1)
a1 = ao(pl)
Construct an AO from a set of polynomial coefficients. The relevant parameters are:
|
'polyval' |
A set of polynomial coefficients. |
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)
Generates an AO with a timeseries with a prescribed spectrum.
The relevant parameters are:
|
'pzmodel' |
a pole/zero model which builds the time-series AO |
|
'Nsecs' |
number of seconds to be generated [default: 0] |
|
'fs' |
sampling frequency [default: 0] |
You can also specify optional parameters:
|
'xunits' |
unit of the x-axis [default: 's'] |
|
'yunits' |
unit of the y-axis |
p = [pz(1,2) pz(10)]
z = [pz(4)]
pzm = pzmodel(1, p, z)
fs = 10
nsecs = 100
pl = plist('pzmodel', pzm, 'Nsecs', nsecs, 'Fs', fs)
a1 = ao(pl)
|
Constructor Examples | Constructor examples of the MFIR class | ![]() |
©LTP Team