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] ]
                             'num_columns'  Maximum colums in the file
                                            [default: 50]
                             '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.
       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: []]

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

Generated on Mon 25-Aug-2008 22:39:29 by m2html © 2003