Home > classes > @ao > ao.m

ao

PURPOSE ^

AO analysis object class constructor.

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

 AO analysis object class constructor.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: AO analysis object class constructor.
              Create an analysis object.

     Possible constructors:

       a = ao()            - creates an empty analysis object
       a = ao('a1.xml')    - creates a new analysis object by loading the
                             analysis object from disk.
       a = ao('a1.mat')    - creates a new analysis object by loading the
                             analysis object from disk.
       a = ao('a1.mat')    - creates a new analysis object by loading the
                             2-column data set stored in the .MAT file.
       a = ao('file.txt')  - creates a new analysis object by loading the
       a = ao('file.dat')    data in 'file.txt'. The ascii file is assumed
                             to be an equally sampled two-column file of
                             time and amplitude. By default, the amplitude
                             units are taken to be Volts ('V') and the
                             time samples are assumed to be in seconds.
       a = ao('file',pl)   - 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 array]
                             'columns'      [1 2 1 4]
                                            Each pair represented the x- and y-axes.
                                            (Each column pair creates an analysis object)
                                            Is the value 'use_fs' is used then
                                            represent each column the y-axes.
                                            (Each column creates an analysis object)
                                            [default: [1 2] ]
                             'comment_char' The comment character in the file
                                            [default: '']
                             'description'  To set the description in the analysis object
                             '...'          every property where exist a public
                                            set-function in the AO class e.g.
                                            setName, setT0, setYunits, ...
                             If the constructor creates multiple ao's it is
                             possible to give each data class its own e.g.
                             'name'. In this case the parameter list with the
                             key 'name' must have cell of the different values
                             as the name of the different data objects. e.g.
                             pl = plist('columns', [1 2 1 3],        ...
                                        'name',   {'name1' 'name2'}, ...
                                        'xunits', 'sec',             ...
                                        'yunits', {'V' 'Hz'});
                             This parameter list creates two ao's with tsdata.

                             'Robust'  - set this to 'yes' to use (slow)
                                         robust data reading. Useful for
                                         complicated file formats.
                                         [default: 'yes']

       NOTE: Data files with comments at the end of the lines can only be
       read if there are no lines with only comments. In this case, do not
       specify a comment character. If you really want to load a file like
       this, specify the 'Robust' option; this will be very slow for large
       files.

       a = ao(data)        - creates an analysis object with a data
                             object. Data object can be one of tsdata,
                             fsdata, cdata, xydata, xyzdata.
       a = ao(data, hist)  - creates an analysis object with a data
                             object and a history object
       a = ao(specwin)     - creates an analysis object from a specwin
                             object
       a = ao(plist)       - creates an analysis object from the description
                             given in the parameter list

 Parameter sets for plist constructor (in order of priority):

 From XML File
 -------------

   Construct an AO by loading it from an XML file.

   'filename' - construct an AO from a filename.
                Example: plist('filename', 'a1.xml')
                [default: empty string]

 From MAT File
 -------------

   Construct an AO by loading it from a MAT file.

   'filename' - construct an AO from a filename.
                Example: plist('filename', 'a1.mat')
                [default: empty string]

 From ASCII File
 ---------------

   Construct an AO by loading it from an ASCII text file.

   'filename' - construct an AO from a filename.
                Example: plist('filename', 'a1.txt')
                [default: empty string]

   For additional parameters, see constructor ao(file, pl) above.

 From Function
 -------------

   Construct an AO from the description of any valid MATLAB function.

   'fcn'      - any valid MATLAB function.
                Example: plist('fcn', 'randn(100,1)')

                You can pass additional parameters to the fcn as extra
                parameters in the parameter list:
                plist('fcn', 'a*b', 'a', 2, 'b', 1:20);

                ** Note: case is ignored in the function specification
                such the following:
                  plist('fcn', 'a*A/b', 'a', 2, 'B', 1:20);
                results in:
                  2*2*[1:20]

                [default: 'randn(100,1)']

 From Values
 -----------

   Construct an AO from a set of values.

   'vals'     - a set of values.
                Example: plist('vals', [1 2 3])
                optional parameter: repeat 'N' times
                Example: plist('vals', [1 2 3], 'N', 10)

                [default: vals: [1], N: [1] ]
  OR

   To produce a tsdata AO

   'xvals'     - a set of x values.
   'yvals'     - a set of y values.



 From Time-series Function
 -------------------------

   Construct an AO from a function of time, t.

   'tsfcn'    - a function of time.

                You can also specify optional 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 [default: time(0)]
                Example:
                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'));

 From Frequency-series Function
 ------------------------------

   Construct an AO from a function of frequency, f.

   'fsfcn'    - a function of frequency, f.   [default: 'f']

                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 [default: [] ]

 From Window
 -----------

   Construct an AO from a spectral window object.

   'win'      - A specwin object.

                This creates a cdata type AO containing the window values.
                Example: plist('win', specwin('Hannning', 100))

                [default: specwin('Hanning', 100)]

 From Waveform
 -------------

   Construct an AO from a waveform description.

   'waveform' - a waveform description (see options below).

                You can also specify additional parameters:
                'fs'      - sampling frequency [default: 10 Hz]
                'nsecs'   - length in seconds [default: 10 s]

                and, for the following waveform types:
                'sine wave'      - 'A', 'f', 'phi' (can be vectors for sum
                                   of sine waves)
                '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 the initial time (t0) associated with
                the time-series by passing a parameter 't0' with a value
                that is a time object.

                [defaults: waveform: 'sine wave', A: 1, f: 1.23, phi: 0,
                           fs: 10, nsecs: 10, t0: time(0) ]


 From Repository
 ---------------

   Construct an AO by retrieving it from an LTPDA repository.

   'Hostname' - the repository hostname. Only those objects which
                are AOs are returned.
                [default: 'localhost'];

                Additional parameters:

                'Database'   - The database name [default: 'ltpda']
                'ID'         - A vector of object IDs. [default: []]
                'CID'        - Retrieve all AO objects from a particular
                               collection.

 From Polynomial
 ---------------

   Construct an AO from a set of polynomial coefficients.

   'polyval'  - a set of polynomial coefficients.
                [default: [-0.0001 0.02 -1 -1] ]

                Additional parameters:
                   'Nsecs' and 'fs'  - number of seconds, and sample rate
                                       [defaults: nsecs: 10, fs: 10]
                or 't'               - vector of time vertices
                                       [default: [] ]

                Example:  a = ao(plist('polyval', [1 2 3], 'Nsecs', 10, 'fs', 10));


 From Plist
 ----------

   'Plist'    - construct from a plist. The value passed should be a plist
                object.
                [default: empty plist]



   Examples:

   1) Normally distributed random noise time-series

      p     = plist('waveform', 'noise', 'fs', 10, 'nsecs', 1000);
      rd10  = ao(p);


     Indexing:
       b = a(1)            % where a is an array of analysis objects
       d = a.data;         % get the data object
       h = a.hist;         % get the history object
       d = a.data.x(1:20); % get a matrix of data values x;

 The following call returns an minfo object that contains information
 about the AO constructor:

 >> info = ao.getInfo

 You can get information about class methods by calling:

 >> info = ao.getInfo(method)

 e.g. info = ao.getInfo('pwelch')

 You can also restrict the sets of parameters contained in the minfo
 object by calling:

 >> info = ao.getInfo(method, set)

 e.g., info = ao.getInfo('ao', 'From Vals')

 See also tsdata, fsdata, xydata, cdata, xyzdata

 M Hewitson 30-01-07

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % AO analysis object class constructor.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: AO analysis object class constructor.
0005 %              Create an analysis object.
0006 %
0007 %     Possible constructors:
0008 %
0009 %       a = ao()            - creates an empty analysis object
0010 %       a = ao('a1.xml')    - creates a new analysis object by loading the
0011 %                             analysis object from disk.
0012 %       a = ao('a1.mat')    - creates a new analysis object by loading the
0013 %                             analysis object from disk.
0014 %       a = ao('a1.mat')    - creates a new analysis object by loading the
0015 %                             2-column data set stored in the .MAT file.
0016 %       a = ao('file.txt')  - creates a new analysis object by loading the
0017 %       a = ao('file.dat')    data in 'file.txt'. The ascii file is assumed
0018 %                             to be an equally sampled two-column file of
0019 %                             time and amplitude. By default, the amplitude
0020 %                             units are taken to be Volts ('V') and the
0021 %                             time samples are assumed to be in seconds.
0022 %       a = ao('file',pl)   - creates a new analysis object by loading the
0023 %                             data in 'file'. The parameter list decide how the
0024 %                             analysis object is created. The valid key values
0025 %                             of the parameter list are:
0026 %                             'type'        'tsdata','fsdata','xydata'
0027 %                                            [default: 'tsdata']
0028 %                             'use_fs'       if this value is set, the
0029 %                                            x-axes is computed by the fs value.
0030 %                                            [default: empty array]
0031 %                             'columns'      [1 2 1 4]
0032 %                                            Each pair represented the x- and y-axes.
0033 %                                            (Each column pair creates an analysis object)
0034 %                                            Is the value 'use_fs' is used then
0035 %                                            represent each column the y-axes.
0036 %                                            (Each column creates an analysis object)
0037 %                                            [default: [1 2] ]
0038 %                             'comment_char' The comment character in the file
0039 %                                            [default: '']
0040 %                             'description'  To set the description in the analysis object
0041 %                             '...'          every property where exist a public
0042 %                                            set-function in the AO class e.g.
0043 %                                            setName, setT0, setYunits, ...
0044 %                             If the constructor creates multiple ao's it is
0045 %                             possible to give each data class its own e.g.
0046 %                             'name'. In this case the parameter list with the
0047 %                             key 'name' must have cell of the different values
0048 %                             as the name of the different data objects. e.g.
0049 %                             pl = plist('columns', [1 2 1 3],        ...
0050 %                                        'name',   {'name1' 'name2'}, ...
0051 %                                        'xunits', 'sec',             ...
0052 %                                        'yunits', {'V' 'Hz'});
0053 %                             This parameter list creates two ao's with tsdata.
0054 %
0055 %                             'Robust'  - set this to 'yes' to use (slow)
0056 %                                         robust data reading. Useful for
0057 %                                         complicated file formats.
0058 %                                         [default: 'yes']
0059 %
0060 %       NOTE: Data files with comments at the end of the lines can only be
0061 %       read if there are no lines with only comments. In this case, do not
0062 %       specify a comment character. If you really want to load a file like
0063 %       this, specify the 'Robust' option; this will be very slow for large
0064 %       files.
0065 %
0066 %       a = ao(data)        - creates an analysis object with a data
0067 %                             object. Data object can be one of tsdata,
0068 %                             fsdata, cdata, xydata, xyzdata.
0069 %       a = ao(data, hist)  - creates an analysis object with a data
0070 %                             object and a history object
0071 %       a = ao(specwin)     - creates an analysis object from a specwin
0072 %                             object
0073 %       a = ao(plist)       - creates an analysis object from the description
0074 %                             given in the parameter list
0075 %
0076 % Parameter sets for plist constructor (in order of priority):
0077 %
0078 % From XML File
0079 % -------------
0080 %
0081 %   Construct an AO by loading it from an XML file.
0082 %
0083 %   'filename' - construct an AO from a filename.
0084 %                Example: plist('filename', 'a1.xml')
0085 %                [default: empty string]
0086 %
0087 % From MAT File
0088 % -------------
0089 %
0090 %   Construct an AO by loading it from a MAT file.
0091 %
0092 %   'filename' - construct an AO from a filename.
0093 %                Example: plist('filename', 'a1.mat')
0094 %                [default: empty string]
0095 %
0096 % From ASCII File
0097 % ---------------
0098 %
0099 %   Construct an AO by loading it from an ASCII text file.
0100 %
0101 %   'filename' - construct an AO from a filename.
0102 %                Example: plist('filename', 'a1.txt')
0103 %                [default: empty string]
0104 %
0105 %   For additional parameters, see constructor ao(file, pl) above.
0106 %
0107 % From Function
0108 % -------------
0109 %
0110 %   Construct an AO from the description of any valid MATLAB function.
0111 %
0112 %   'fcn'      - any valid MATLAB function.
0113 %                Example: plist('fcn', 'randn(100,1)')
0114 %
0115 %                You can pass additional parameters to the fcn as extra
0116 %                parameters in the parameter list:
0117 %                plist('fcn', 'a*b', 'a', 2, 'b', 1:20);
0118 %
0119 %                ** Note: case is ignored in the function specification
0120 %                such the following:
0121 %                  plist('fcn', 'a*A/b', 'a', 2, 'B', 1:20);
0122 %                results in:
0123 %                  2*2*[1:20]
0124 %
0125 %                [default: 'randn(100,1)']
0126 %
0127 % From Values
0128 % -----------
0129 %
0130 %   Construct an AO from a set of values.
0131 %
0132 %   'vals'     - a set of values.
0133 %                Example: plist('vals', [1 2 3])
0134 %                optional parameter: repeat 'N' times
0135 %                Example: plist('vals', [1 2 3], 'N', 10)
0136 %
0137 %                [default: vals: [1], N: [1] ]
0138 %  OR
0139 %
0140 %   To produce a tsdata AO
0141 %
0142 %   'xvals'     - a set of x values.
0143 %   'yvals'     - a set of y values.
0144 %
0145 %
0146 %
0147 % From Time-series Function
0148 % -------------------------
0149 %
0150 %   Construct an AO from a function of time, t.
0151 %
0152 %   'tsfcn'    - a function of time.
0153 %
0154 %                You can also specify optional parameters
0155 %                'fs'      - sampling frequency [default: 10 Hz]
0156 %                'nsecs'   - length in seconds [default: 10 s]
0157 %
0158 %                You can also specify the initial time (t0) associated with
0159 %                the time-series by passing a parameter 't0' with a value
0160 %                that is a time object [default: time(0)]
0161 %                Example:
0162 %                plist('fs', 10, 'nsecs', 10, ...
0163 %                'tsfcn', 'sin(2*pi*1.4*t) + 0.1*randn(size(t))', ...
0164 %                't0', time('1980-12-01 12:43:12'));
0165 %
0166 % From Frequency-series Function
0167 % ------------------------------
0168 %
0169 %   Construct an AO from a function of frequency, f.
0170 %
0171 %   'fsfcn'    - a function of frequency, f.   [default: 'f']
0172 %
0173 %                You can also specify optional parameters:
0174 %                   'f1'    - the initial frequency  [default: 1e-9]
0175 %                   'f2'    - the final frequency    [default: 5]
0176 %                   'nf'    - the number of frequency samples [default: 1000]
0177 %                   'scale' - 'log' or 'lin' frequency spacing [default: 'log']
0178 %                or provide a frequency vector:
0179 %                   'f' - a vector of frequencies on which to evaluate the
0180 %                         function [default: [] ]
0181 %
0182 % From Window
0183 % -----------
0184 %
0185 %   Construct an AO from a spectral window object.
0186 %
0187 %   'win'      - A specwin object.
0188 %
0189 %                This creates a cdata type AO containing the window values.
0190 %                Example: plist('win', specwin('Hannning', 100))
0191 %
0192 %                [default: specwin('Hanning', 100)]
0193 %
0194 % From Waveform
0195 % -------------
0196 %
0197 %   Construct an AO from a waveform description.
0198 %
0199 %   'waveform' - a waveform description (see options below).
0200 %
0201 %                You can also specify additional parameters:
0202 %                'fs'      - sampling frequency [default: 10 Hz]
0203 %                'nsecs'   - length in seconds [default: 10 s]
0204 %
0205 %                and, for the following waveform types:
0206 %                'sine wave'      - 'A', 'f', 'phi' (can be vectors for sum
0207 %                                   of sine waves)
0208 %                'noise'          - 'type' (can be 'Normal' or 'Uniform')
0209 %                'chirp'          - 'f0', 'f1', 't1'      (help chirp)
0210 %                'Gaussian pulse' - 'f0', 'bw'            (help gauspuls)
0211 %                'Square wave'    - 'f', 'duty'           (help square)
0212 %                'Sawtooth'       - 'f', 'width'          (help sawtooth)
0213 %
0214 %                You can also specify the initial time (t0) associated with
0215 %                the time-series by passing a parameter 't0' with a value
0216 %                that is a time object.
0217 %
0218 %                [defaults: waveform: 'sine wave', A: 1, f: 1.23, phi: 0,
0219 %                           fs: 10, nsecs: 10, t0: time(0) ]
0220 %
0221 %
0222 % From Repository
0223 % ---------------
0224 %
0225 %   Construct an AO by retrieving it from an LTPDA repository.
0226 %
0227 %   'Hostname' - the repository hostname. Only those objects which
0228 %                are AOs are returned.
0229 %                [default: 'localhost'];
0230 %
0231 %                Additional parameters:
0232 %
0233 %                'Database'   - The database name [default: 'ltpda']
0234 %                'ID'         - A vector of object IDs. [default: []]
0235 %                'CID'        - Retrieve all AO objects from a particular
0236 %                               collection.
0237 %
0238 % From Polynomial
0239 % ---------------
0240 %
0241 %   Construct an AO from a set of polynomial coefficients.
0242 %
0243 %   'polyval'  - a set of polynomial coefficients.
0244 %                [default: [-0.0001 0.02 -1 -1] ]
0245 %
0246 %                Additional parameters:
0247 %                   'Nsecs' and 'fs'  - number of seconds, and sample rate
0248 %                                       [defaults: nsecs: 10, fs: 10]
0249 %                or 't'               - vector of time vertices
0250 %                                       [default: [] ]
0251 %
0252 %                Example:  a = ao(plist('polyval', [1 2 3], 'Nsecs', 10, 'fs', 10));
0253 %
0254 %
0255 % From Plist
0256 % ----------
0257 %
0258 %   'Plist'    - construct from a plist. The value passed should be a plist
0259 %                object.
0260 %                [default: empty plist]
0261 %
0262 %
0263 %
0264 %   Examples:
0265 %
0266 %   1) Normally distributed random noise time-series
0267 %
0268 %      p     = plist('waveform', 'noise', 'fs', 10, 'nsecs', 1000);
0269 %      rd10  = ao(p);
0270 %
0271 %
0272 %     Indexing:
0273 %       b = a(1)            % where a is an array of analysis objects
0274 %       d = a.data;         % get the data object
0275 %       h = a.hist;         % get the history object
0276 %       d = a.data.x(1:20); % get a matrix of data values x;
0277 %
0278 % The following call returns an minfo object that contains information
0279 % about the AO constructor:
0280 %
0281 % >> info = ao.getInfo
0282 %
0283 % You can get information about class methods by calling:
0284 %
0285 % >> info = ao.getInfo(method)
0286 %
0287 % e.g. info = ao.getInfo('pwelch')
0288 %
0289 % You can also restrict the sets of parameters contained in the minfo
0290 % object by calling:
0291 %
0292 % >> info = ao.getInfo(method, set)
0293 %
0294 % e.g., info = ao.getInfo('ao', 'From Vals')
0295 %
0296 % See also tsdata, fsdata, xydata, cdata, xyzdata
0297 %
0298 % M Hewitson 30-01-07
0299 %
0300 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0301 
0302 
0303 classdef ao < ltpda_uoh
0304 
0305 
0306   %------------------------------------------------
0307   %-------- Public (read/write) Properties  -------
0308   %------------------------------------------------
0309   properties
0310   end % End (read/write) Properties
0311 
0312   %------------------------------------------------
0313   %---------- Private read-only Properties --------
0314   %------------------------------------------------
0315   properties (SetAccess = protected)
0316     data        = [];
0317     mfile       = '';
0318     mfilename   = '';
0319     mdlfile     = '';
0320     mdlfilename = '';
0321     procinfo    = plist();
0322     plotinfo    = plist();
0323     description = '';
0324     version     = '$Id: ao.m,v 1.158 2008/09/07 18:11:06 hewitson Exp $';
0325   end % End read only properties
0326 
0327   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0328   %                          Check property setting                           %
0329   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0330 
0331   methods
0332     function obj = set.data(obj, val)
0333       if ~(isa(val, 'ltpda_data') || isempty(val))
0334         error('### The value for the property ''data'' must be a ltpda_data object');
0335       end
0336       obj.data = val;
0337     end
0338     function obj = set.mfile(obj, val)
0339       if ~ischar(val)
0340         error('### The value for the property ''mfile'' must be a string');
0341       end
0342       obj.mfile = val;
0343     end
0344     function obj = set.mfilename(obj, val)
0345       if ~ischar(val)
0346         error('### The value for the property ''mfilename'' must be a string');
0347       end
0348       obj.mfilename = val;
0349     end
0350     function obj = set.mdlfile(obj, val)
0351       if ~ischar(val)
0352         error('### The value for the property ''mdlfile'' must be a string');
0353       end
0354       obj.mdlfile = val;
0355     end
0356     function obj = set.mdlfilename(obj, val)
0357       if ~ischar(val)
0358         error('### The value for the property ''mdlfilename'' must be a string');
0359       end
0360       obj.mdlfilename = val;
0361     end
0362     function obj = set.procinfo(obj, val)
0363       if ~isa(val, 'plist')
0364         error('### The value for the property ''procinfo'' should be a plist.');
0365       end
0366       obj.procinfo = val;
0367     end
0368     function obj = set.plotinfo(obj, val)
0369       if ~isa(val, 'plist')
0370         error('### The value for the property ''plotinfo'' should be a plist.');
0371       end
0372       obj.plotinfo = val;
0373     end
0374     function obj = set.description(obj, val)
0375       if ~ischar(val)
0376         error('### The value for the property ''description'' should be a string.');
0377       end
0378       obj.description = val;
0379     end
0380   end
0381 
0382 
0383   %------------------------------------------------
0384   %---------------- Private Properties ------------
0385   %------------------------------------------------
0386   properties (GetAccess = protected, SetAccess = protected)
0387 
0388   end
0389 
0390   methods
0391     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0392     %                               Constructor                               %
0393     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0394     function a = ao(varargin)
0395 
0396       import utils.const.*
0397       utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename);
0398 
0399       % Check the supported version
0400       utils.helper.checkMatlabVersion;
0401 
0402       %%% Call superclass
0403       a = a@ltpda_uoh(varargin{:});
0404 
0405       %%%%%%%%%%   Set dafault values   %%%%%%%%%%
0406 
0407       %%% Collect all plists and combine them.
0408       [pli, invars, args] = utils.helper.collect_objects(varargin, 'plist');
0409 
0410       if ~isempty(pli)
0411         pli = pli.combine();
0412         %%% Append the plist to the input-arguments
0413         args{end+1} = pli;
0414       end
0415 
0416       %%% Execute appropriate constructor
0417       switch numel(args)
0418         case 0
0419           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0420           %%%%%%%%%%%%%%%%%%%%%%%%%%%   no input   %%%%%%%%%%%%%%%%%%%%%%%%%%%%
0421           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0422           utils.helper.msg(msg.PROC1, 'empty constructor');
0423           a.addHistory(ao.getInfo('ao', 'None'), [], [], []);
0424 
0425         case 1
0426           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0427           %%%%%%%%%%%%%%%%%%%%%%%%%%%   one input   %%%%%%%%%%%%%%%%%%%%%%%%%%%
0428           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0429 
0430           if ischar(args{1})
0431             %%%%%%%%%%   a1 = ao('foo.mat')   %%%%%%%%%%
0432             %%%%%%%%%%   a1 = ao('foo.xml')   %%%%%%%%%%
0433             %%%%%%%%%%   a1 = ao('foo.txt')   %%%%%%%%%%
0434             %%%%%%%%%%   a1 = ao('foo.dat')   %%%%%%%%%%
0435 
0436             utils.helper.msg(msg.OPROC1, 'constructing from file %s', varargin{1});
0437             a = fromFile(a, args{1});
0438 
0439           elseif isa(args{1}, 'ao')
0440             %%%%%%%%%%   a1 = ao(ao)   %%%%%%%%%%
0441 
0442             utils.helper.msg(msg.PROC1, 'copying %s', args{1}.name);
0443             a = copy(args{1},1);
0444             for kk = 1:numel(args{1})
0445               a(kk).addHistory(ao.getInfo('ao', 'None'), [], [], a(kk).hist);
0446             end
0447 
0448           elseif isstruct(args{1})
0449             %%%%%%%%%%   a1 = ao(struct)   %%%%%%%%%%
0450 
0451             utils.helper.msg(msg.PROC1, 'constructing from struct');
0452             %%% Set properties which are declared in this class
0453             astruct = args{1};
0454 
0455             if isfield(astruct, 'data')
0456               %%% data -> data-object
0457               if isstruct(astruct.data)
0458                 a.data = utils.helper.struct2obj(astruct.data);
0459               else
0460                 a.data = astruct.data;
0461               end
0462             end
0463             a.mfile       = astruct.mfile;
0464             a.mfilename   = astruct.mfilename;
0465             a.mdlfile     = astruct.mdlfile;
0466             a.mfilename   = astruct.mfilename;
0467             a.procinfo    = utils.helper.struct2obj(astruct.procinfo, 'plist');
0468             a.plotinfo    = utils.helper.struct2obj(astruct.plotinfo, 'plist');
0469             a.description = astruct.description;
0470             a.version     = astruct.version;
0471 
0472           elseif isnumeric(args{1})
0473             %%%%%%%%%%   a1 = ao(constant)   %%%%%%%%%%
0474             %%%%%%%%%%   a1 = ao([1 2; 3 4])   %%%%%%%%%%
0475 
0476             utils.helper.msg(msg.PROC1, 'constructing from values');
0477             a = fromVals(a, plist('VALS', args{1}));
0478 
0479           elseif isa(args{1}, 'plist')
0480             %%%%%%%%%%   a1 = ao(plist-object)   %%%%%%%%%%
0481 
0482             utils.helper.msg(msg.PROC1, 'constructing from plist');
0483             pl         = args{1};
0484             filename   = find(pl, 'filename');
0485             fcn        = find(pl, 'fcn');
0486             vals       = find(pl, 'vals');
0487             xvals      = find(pl, 'xvals');
0488             yvals      = find(pl, 'yvals');
0489             tsfcn      = find(pl, 'tsfcn');
0490             fsfcn      = find(pl, 'fsfcn');
0491             win        = find(pl, 'win');
0492             waveform   = find(pl, 'waveform');
0493             polycoeffs = find(pl, 'polyval');
0494             hostname   = find(pl, 'hostname');
0495             conn       = find(pl, 'conn');
0496             ipl        = find(pl, 'Plist');
0497             pzm        = find(pl, 'pzmodel');
0498 
0499             if ~isempty(filename)
0500 
0501               %-----------------------------------------------------
0502               %--- Construct from file
0503               %-----------------------------------------------------
0504               utils.helper.msg(msg.PROC2, 'constructing from file %s', filename);
0505               a = fromFile(a, args{1});
0506 
0507             elseif ~isempty(fcn)
0508 
0509               %-----------------------------------------------------
0510               %--- Construct from function
0511               %-----------------------------------------------------
0512               utils.helper.msg(msg.PROC2, 'constructing from function %s', fcn);
0513               a = fromFcn(a, pl);
0514 
0515             elseif ~isempty(vals)
0516 
0517               %-----------------------------------------------------
0518               %--- Construct from Values
0519               %-----------------------------------------------------
0520               utils.helper.msg(msg.PROC2, ['constructing from values ' mat2str(vals)]);
0521               a = a.fromVals(pl);
0522 
0523             elseif ~isempty(xvals) && ~isempty(yvals)
0524 
0525               %-----------------------------------------------------
0526               %--- Construct from X and Y Values
0527               %-----------------------------------------------------
0528               utils.helper.msg(msg.PROC2, 'constructing from X and Y values');
0529               a = fromVals(a, pl);
0530 
0531             elseif ~isempty(tsfcn)
0532 
0533               %-----------------------------------------------------
0534               %--- Construct from Time-series function
0535               %-----------------------------------------------------
0536               utils.helper.msg(msg.PROC2, 'constructing from fcn(t) %s', tsfcn);
0537               a = fromTSfcn(a, pl);
0538 
0539             elseif ~isempty(fsfcn)
0540 
0541               %-----------------------------------------------------
0542               %--- Construct from frequency-series function
0543               %-----------------------------------------------------
0544               utils.helper.msg(msg.PROC2, 'constructing from fcn(f) %s', fsfcn);
0545               a = a.fromFSfcn(pl);
0546 
0547             elseif ~isempty(win)
0548 
0549               %-----------------------------------------------------
0550               %--- Construct from Window
0551               %-----------------------------------------------------
0552               utils.helper.msg(msg.PROC2, 'constructing from window %s', char(win));
0553               a = a.fromSpecWin(pl);
0554 
0555             elseif ~isempty(waveform)
0556 
0557               %-----------------------------------------------------
0558               %--- Construct from Waveform
0559               %-----------------------------------------------------
0560               utils.helper.msg(msg.PROC2, 'constructing from waveform %s', waveform);
0561               a = fromWaveform(a, pl);
0562 
0563             elseif ~isempty(hostname) || ~isempty(conn)
0564 
0565               %-----------------------------------------------------
0566               %--- Construct from repository
0567               %-----------------------------------------------------
0568               utils.helper.msg(msg.PROC2, 'constructing from repository %s', hostname);
0569               a = a.fromRepository(pl);
0570 
0571             elseif ~isempty(polycoeffs)
0572 
0573               %-----------------------------------------------------
0574               %--- Construct from polynomial
0575               %-----------------------------------------------------
0576               utils.helper.msg(msg.PROC2, ['constructing from polynomial ' mat2str(polycoeffs)]);
0577               a = a.fromPolyval(pl);
0578 
0579             elseif ~isempty(ipl)
0580 
0581               %-----------------------------------------------------
0582               %--- Construct from plist
0583               %-----------------------------------------------------
0584               % if the plist is empty, we return an empty ao
0585               if nparams(ipl) == 0
0586               else
0587                 % do plist constructor
0588                 a = ao(ipl);
0589               end
0590 
0591             elseif ~isempty(pzm)
0592 
0593               %-----------------------------------------------------
0594               %--- Construct from pzmodel
0595               %-----------------------------------------------------
0596               utils.helper.msg(msg.PROC2, 'constructing from pzmodel %s', char(pzm));
0597               a = a.fromPzmodel(pl);
0598 
0599             else
0600               %-----------------------------------------------------
0601               %--- ERROR
0602               %-----------------------------------------------------
0603               if nparams(pl) == 0
0604                 %%% is the plist is empty then return an empty AO
0605                 a = ao();
0606               else
0607                 error('### Unknown AO constructor method.');
0608               end
0609             end
0610 
0611           elseif isa(args{1}, 'specwin')
0612             %%%%%%%%%%   a1 = ao(specwin)   %%%%%%%%%%
0613 
0614             utils.helper.msg(msg.PROC1, 'constructing from spectral window %s', char(args{1}));
0615             a = a.fromSpecWin(args{1});
0616 
0617           elseif isa(args{1}, 'ltpda_data')
0618             %%%%%%%%%%   a1 = ao(ltpda_data-object)   %%%%%%%%%%
0619             %%%%%%%%%%   a1 = ao(cdata)               %%%%%%%%%%
0620             %%%%%%%%%%   a1 = ao(fsdata)              %%%%%%%%%%
0621             %%%%%%%%%%   a1 = ao(tsdata)              %%%%%%%%%%
0622             %%%%%%%%%%   a1 = ao(xydata)              %%%%%%%%%%
0623             %%%%%%%%%%   a1 = ao(xyzdata)             %%%%%%%%%%
0624 
0625             utils.helper.msg(msg.PROC1, 'constructing from data object %s', class(args{1}));
0626             a             = ao;
0627             a.data        = args{1};
0628             a.addHistory(ao.getInfo('ao', 'None'), [], [], []);
0629 
0630           else
0631             error('### Unknown single input constructor');
0632           end
0633 
0634         case 2
0635           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0636           %%%%%%%%%%%%%%%%%%%%%%%%%%%   two inputs   %%%%%%%%%%%%%%%%%%%%%%%%%%
0637           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0638 
0639           if isa(varargin{1}, 'database')
0640             %%%%%%%%%%   ao(database-object, [IDs])   %%%%%%%%%%
0641 
0642             utils.helper.msg(msg.PROC1, 'constructing from database object');
0643             pl = plist('conn', varargin{1}, 'id', varargin{2});
0644             a = a.fromRepository(pl);
0645 
0646           elseif isnumeric(args{1}) && isnumeric(args{2})
0647             %%%%%%%%%%   ao(x-vector, y-vector)   %%%%%%%%%%
0648 
0649             utils.helper.msg(msg.PROC1, 'constructing from X and Y values');
0650             a = a.fromVals(plist('XVALS', args{1}, 'YVALS', args{2}));
0651 
0652           elseif ischar(args{1}) && isa(args{2}, 'plist')
0653             %%%%%%%%%%%   ao('foo.txt', pl)   %%%%%%%%%%
0654 
0655             utils.helper.msg(msg.PROC1, 'constructing from filename and plist');
0656             pl = combine(plist('filename', args{1}), args{2});
0657             a = a.fromFile(pl);
0658 
0659           elseif isa(args{1}, 'ao') && isa(args{2}, 'ao')
0660             %%%%%%%%%%%   ao(ao-object, ao-object)   %%%%%%%%%%
0661             % Do we have a list of AOs as input
0662             a = ao([args{1}, args{2}]);
0663 
0664           elseif isa(args{1}, 'ao') && isa(args{2}, 'plist') && isempty(args{2}.params)
0665             % pass to copy constructor
0666             a = ao(args{1});
0667           elseif isa(args{1}, 'ao') && isa(args{2}, 'plist')
0668             %%%%%%%%%%%   ao(ao-object, plist-object)   %%%%%%%%%%
0669             % This constructor is necessary for the function type.
0670             % Ignore the first AO and build a new AO from the plist.
0671 
0672             a = ao(args{2});
0673           else
0674             error('### Unknown constructor with two inputs');
0675           end
0676 
0677         otherwise
0678           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0679           %%%%%%%%%%%%%%%%%%%%%%%%%%   other inputs   %%%%%%%%%%%%%%%%%%%%%%%%%
0680           %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0681 
0682           [aoi, invars, rest] = utils.helper.collect_objects(args, 'ao');
0683 
0684           %%% Do we have a list of AOs as input
0685           if ~isempty(aoi) && isempty(rest)
0686             a = ao(aoi);
0687           else
0688             error('### Unknown number of arguments.');
0689           end
0690       end
0691     end % End constructor
0692   end % End public methods
0693 
0694 
0695   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0696   %                            Methods (static)                               %
0697   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0698   methods (Static=true)
0699     varargout = mdc1_input_noises(varargin)
0700     varargout = update_struct(varargin);
0701 
0702     function out = SETS()
0703       out = {...
0704         'Default', ...
0705         'From XML File', 'From MAT File', 'From ASCII File',...
0706         'From Function', 'From Values',...
0707         'From Time-series Function', 'From Frequency-series Function', ...
0708         'From Window', 'From Waveform', 'From Polynomial', 'From Repository',...
0709         'From Plist', 'From Pzmodel'};
0710     end
0711 
0712     function out = VEROUT()
0713       out = '$Id: ao.m,v 1.158 2008/09/07 18:11:06 hewitson Exp $';
0714     end
0715 
0716     function ii = getInfo(varargin)
0717       ii = utils.helper.generic_getInfo(varargin{:}, 'ao');
0718     end
0719 
0720     % Return the plist for a particular parameter set
0721     function out = getDefaultPlist(set)
0722 
0723       % Otherwise we try to find a set for this constructor
0724       switch set
0725         case 'Default'
0726           out = plist();
0727 
0728           %------------------------------------------
0729           %--- Repository constructor
0730           %------------------------------------------
0731         case 'From Repository'
0732           out = plist('hostname', 'localhost', 'database', 'ltpda', 'ID', []);
0733 
0734           %------------------------------------------
0735           %--- Read from XML file
0736           %------------------------------------------
0737         case 'From XML File'
0738           out = plist('filename', '');
0739 
0740           %------------------------------------------
0741           %--- Read from MAT file
0742           %------------------------------------------
0743         case 'From MAT File'
0744           out = plist('filename', '');
0745 
0746           %------------------------------------------
0747           %--- Read from ASCII file
0748           %------------------------------------------
0749         case 'From ASCII File'
0750           out = plist(...
0751             'filename',    '',...
0752             'type',        'tsdata',...
0753             'columns',      [1 2],...
0754             'xunits',        unit('s'), ...
0755             'yunits',        unit('V'), ...
0756             't0',            time(0),...
0757             'comment_char', '', ...
0758             'use_fs',       '', ...
0759             'Robust', 'yes');
0760 
0761           %------------------------------------------
0762           %--- Create from a function description
0763           %------------------------------------------
0764         case 'From Function'
0765           out = plist('fcn', 'randn(100,1)');
0766 
0767           %------------------------------------------
0768           %--- Create from a set of values
0769           %------------------------------------------
0770         case 'From Values'
0771           out = plist('vals', 1, 'N', 1);
0772 
0773           %------------------------------------------
0774           %--- Create from a time-series function
0775           %------------------------------------------
0776         case 'From Time-series Function'
0777           out = plist('tsfcn', 't', 'fs', 10, 'nsecs', 1, 't0', time(0));
0778 
0779           %------------------------------------------
0780           %--- Create from frequency-series function
0781           %------------------------------------------
0782         case 'From Frequency-series Function'
0783           out = plist('fsfcn', 'f', 'f1', 1e-9, 'f2', 5, 'nf', 1000, 'scale', 'log', 'f', []);
0784 
0785           %------------------------------------------
0786           %--- Create from a window function
0787           %------------------------------------------
0788         case 'From Window'
0789           out = plist('win', specwin('Hanning', 100));
0790 
0791           %------------------------------------------
0792           %--- Create from a set of polynomial coefficients
0793           %------------------------------------------
0794         case 'From Polynomial'
0795           out = plist('polyval', [-1e-4 .02 -1 -1], 'Nsecs', 10, 'fs', 10, 't', []);
0796 
0797           %------------------------------------------
0798           %--- Create from a plist
0799           %------------------------------------------
0800         case 'From Plist'
0801           out = plist('Plist', plist);
0802 
0803           %------------------------------------------
0804           %--- Create from a waveform description
0805           %------------------------------------------
0806         case 'From Waveform'
0807           out = plist('waveform', 'sine wave',...
0808             'A', 1, ...
0809             'f', 1.23,...
0810             'phi', 0,...
0811             'fs', 10,...
0812             'nsecs', 10,...
0813             't0', time(0));
0814 
0815           %------------------------------------------
0816           %--- Create from a set of polynomial coefficients
0817           %------------------------------------------
0818         case 'From Pzmodel'
0819           out = plist('pzmodel', pzmodel, 'Nsecs', 0, 'fs', 0);
0820         otherwise
0821           out = plist();
0822       end
0823     end % End getDefaultPlist
0824   end
0825 
0826 
0827   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0828   %                         Methods (public)                                  %
0829   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0830   methods
0831     % Getters
0832     val = xunits(varargin)
0833     val = yunits(varargin)
0834     val = fs(varargin)
0835     val = t0(varargin)
0836     val = x(varargin)
0837     val = y(varargin)
0838   end
0839 
0840   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0841   %                         Methods (static, private)                         %
0842   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0843   methods (Static=true, Access=private)
0844     % constructor functions
0845     % Spectral estimate function
0846     [yy, info] = welchscale(xx, win, fs, norm, inunits)
0847     varargout = welch(varargin)
0848     [x,M,isreal_x,y,Ly,win,winName,winParam,noverlap,k,L,options] = welchparse(x,esttype,varargin)
0849     [P,f] = computeperiodogram(x,win,nfft,esttype,varargin)
0850     [Xx,f] = computeDFT(xin,nfft,varargin)
0851     varargout = xspec(varargin)
0852 
0853     % Noise generator functions
0854     varargout = ngconv(varargin)
0855     varargout = ngsetup(varargin)
0856     varargout = ngsetup_vpa(varargin)
0857     varargout = nginit(varargin)
0858     varargout = ngprop(varargin)
0859     varargout = fq2fac(varargin)
0860     varargout = conv_noisegen(varargin)
0861     varargout = mchol(varargin)
0862 
0863     % LPSD-type methods
0864     varargout = ltf_plan(varargin)
0865     varargout = mlpsd_mex(varargin)
0866     varargout = mlpsd_m(varargin)
0867     varargout = mltfe(varargin)
0868     varargout = findFsMax(varargin)
0869     varargout = findShortestVector(varargin)
0870     varargout = lxspec(varargin)
0871   end
0872 
0873 
0874   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0875   %                              Methods (public)                             %
0876   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0877   methods
0878 
0879     % Setters
0880     varargout = setXunits(varargin)
0881     varargout = setYunits(varargin)
0882     varargout = setT0(varargin)
0883     varargout = setFs(varargin)
0884     varargout = setXY(varargin)
0885     varargout = setY(varargin)
0886     varargout = setX(varargin)
0887     varargout = setDescription(varargin)
0888     varargout = setZ(varargin)
0889 
0890 
0891     % Other methods
0892     varargout = copy(varargin)
0893     h = md5(varargin)
0894   end % End public methods
0895 
0896 
0897   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0898   %                             Methods (protected)                           %
0899   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0900   methods (Access = protected)
0901     obj = fromDataInMAT(obj, data, filename)
0902     obj = fromDatafile(obj, pli)
0903   end
0904 
0905 
0906   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0907   %                           Methods (private)                               %
0908   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0909   methods (Access=private)
0910     % Constructors
0911     a = fromVals(a, pli)
0912     a = fromTSfcn(a, pli)
0913     a = fromWaveform(a, pli)
0914     a = fromFcn(a,pli)
0915     a = fromFSfcn(a,pli)
0916     a = fromSpecWin(a,pli)
0917     a = fromPolyval(a,pli)
0918     a = fromPzmodel(a,pli)
0919     % Others
0920     varargout = applymethod(varargin)
0921     varargout = applyoperator(varargin)
0922   end
0923 
0924 end

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003