Home > classes > @ao > ao.m

ao

PURPOSE ^

AO analysis object class constructor.

SYNOPSIS ^

function varargout = ao(varargin)

DESCRIPTION ^

 AO analysis object class constructor.

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

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

     Properties:
       name       - name of analysis object
       data       - data object (tsdata, fsdata)
       history    - history object
       provenance - creation info, machine, user, etc


     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('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.
                             'columns'      [1 2 1 4]
                                            default = [1 2]
                                            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)
                             'num_columns'  Maximum colums in the file
                                            default = 10
                             'comment_char' The comment character in the file
                                            default = '%'
                             'description'  To set the description in the analysis object
                             '...'          every property of the data object
                                            e.g. 'name'
                             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(plist)       - creates an analysis object with by reading
                             the file specified by the 'filename'
                             parameter in the plist.
       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

 Parameters for plist constructor:

   'filename' - construct an AO from a filename.
                Example: plist(param('filename', 'a1.xml'))

   'fcn'      - construct an AO from some valid MATLAB function.
                Example: plist(param('fcn', 'randn(100)'))

   'vals'     - construct an AO from a set of values.
                Example: plist(param('vals', [1 2 3]))

   'tsfcn'    - construct an AO from a function of time. You need to also
                specify parameters 'fs' and 'nsecs' for this call.
                Example:
                  plist([param('fs', 10) param('nsecs', 10) param('tsfcn',
                  'sin(2*pi*1.4*t) + 0.1*randn(size(t))')])

   'fsfcn'    - construct an AO from a function of frequency (f). You also
                need to specify:
                   'f1'    - the initial frequency
                   'f2'    - the final frequency
                   'nf'    - the number of frequency samples
                   'scale' - 'log' or 'lin' frequency spacing
                or provide a frequency vector:
                   'f' - a vector of frequencies on which to evaluate the
                         function

   'win'      - construct an AO from a specwin window function. Tjis
                creates a cdata type AO containing the window values.
                Example: plist(param('win', specwin('Hannning', 100)))

   'waveform' - construct an AO from a waveform description. Here you need
                to specify additional parameters 'fs' and 'nsecs', and also,
                for the following waveform types:
                'sine wave'      - 'f', 'phi'
                'noise'          - 'type' (can be 'Normal' or 'Uniform')
                'chirp'          - 'f0', 'f1', 't1'      (help chirp)
                'Gaussian pulse' - 'f0', 'bw'            (help gauspuls)
                'Square wave'    - 'f', 'duty'           (help square)
                'Sawtooth'       - 'f', 'width'          (help sawtooth)

   'Hostname' - construct an AO by retrieving it from an LTPDA repository
                specified by the given hostname. Only those objects which
                are AOs are returned.
                Additional parameters:
                'Database'   - The database name [default: 'ltpda']
                'ID'         - A vector of object IDs.

   'Plist'    - construct from a plist. The value passed should be a plist
                object.

   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 a parameter list object that contains the
 default parameter values:

 >> pl = ao(ao, 'Params')

 The following call returns a string that contains the routine CVS version:

 >> version = ao(ao,'Version')

 The following call returns a string that contains the routine category:

 >> category = ao(ao,'Category')

 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 function varargout = ao(varargin)
0002 % AO analysis object class constructor.
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: AO analysis object class constructor.
0007 %              Create an analysis object.
0008 %
0009 %     Properties:
0010 %       name       - name of analysis object
0011 %       data       - data object (tsdata, fsdata)
0012 %       history    - history object
0013 %       provenance - creation info, machine, user, etc
0014 %
0015 %
0016 %     Possible constructors:
0017 %
0018 %       a = ao()            - creates an empty analysis object
0019 %       a = ao('a1.xml')    - creates a new analysis object by loading the
0020 %                             analysis object from disk.
0021 %       a = ao('file.txt')  - creates a new analysis object by loading the
0022 %       a = ao('file.dat')    data in 'file.txt'. The ascii file is assumed
0023 %                             to be an equally sampled two-column file of
0024 %                             time and amplitude. By default, the amplitude
0025 %                             units are taken to be Volts ('V') and the
0026 %                             time samples are assumed to be in seconds.
0027 %       a = ao('file',pl)   - creates a new analysis object by loading the
0028 %                             data in 'file'. The parameter list decide how the
0029 %                             analysis object is created. The valid key values
0030 %                             of the parameter list are:
0031 %                             'type'        'tsdata','fsdata','xydata'
0032 %                                            default = 'tsdata'
0033 %                             'use_fs'       if this value is set, the
0034 %                                            x-axes is computed by the fs value.
0035 %                             'columns'      [1 2 1 4]
0036 %                                            default = [1 2]
0037 %                                            Each pair represented the x- and y-axes.
0038 %                                            (Each column pair creates an analysis object)
0039 %                                            Is the value 'use_fs' is used then
0040 %                                            represent each column the y-axes.
0041 %                                            (Each column creates an analysis object)
0042 %                             'num_columns'  Maximum colums in the file
0043 %                                            default = 10
0044 %                             'comment_char' The comment character in the file
0045 %                                            default = '%'
0046 %                             'description'  To set the description in the analysis object
0047 %                             '...'          every property of the data object
0048 %                                            e.g. 'name'
0049 %                             If the constructor creates multiple ao's it is
0050 %                             possible to give each data class its own e.g.
0051 %                             'name'. In this case the parameter list with the
0052 %                             key 'name' must have cell of the different values
0053 %                             as the name of the different data objects. e.g.
0054 %                             pl = plist('columns', [1 2 1 3],        ...
0055 %                                        'name',   {'name1' 'name2'}, ...
0056 %                                        'xunits', 'sec',             ...
0057 %                                        'yunits', {'V' 'Hz'});
0058 %                             This parameter list creates two ao's with tsdata.
0059 %       a = ao(plist)       - creates an analysis object with by reading
0060 %                             the file specified by the 'filename'
0061 %                             parameter in the plist.
0062 %       a = ao(data)        - creates an analysis object with a data
0063 %                             object. Data object can be one of tsdata,
0064 %                             fsdata, cdata, xydata, xyzdata.
0065 %       a = ao(data, hist)  - creates an analysis object with a data
0066 %                             object and a history object
0067 %
0068 %       a = ao(specwin)     - creates an analysis object from a specwin
0069 %                             object
0070 %
0071 % Parameters for plist constructor:
0072 %
0073 %   'filename' - construct an AO from a filename.
0074 %                Example: plist(param('filename', 'a1.xml'))
0075 %
0076 %   'fcn'      - construct an AO from some valid MATLAB function.
0077 %                Example: plist(param('fcn', 'randn(100)'))
0078 %
0079 %   'vals'     - construct an AO from a set of values.
0080 %                Example: plist(param('vals', [1 2 3]))
0081 %
0082 %   'tsfcn'    - construct an AO from a function of time. You need to also
0083 %                specify parameters 'fs' and 'nsecs' for this call.
0084 %                Example:
0085 %                  plist([param('fs', 10) param('nsecs', 10) param('tsfcn',
0086 %                  'sin(2*pi*1.4*t) + 0.1*randn(size(t))')])
0087 %
0088 %   'fsfcn'    - construct an AO from a function of frequency (f). You also
0089 %                need to specify:
0090 %                   'f1'    - the initial frequency
0091 %                   'f2'    - the final frequency
0092 %                   'nf'    - the number of frequency samples
0093 %                   'scale' - 'log' or 'lin' frequency spacing
0094 %                or provide a frequency vector:
0095 %                   'f' - a vector of frequencies on which to evaluate the
0096 %                         function
0097 %
0098 %   'win'      - construct an AO from a specwin window function. Tjis
0099 %                creates a cdata type AO containing the window values.
0100 %                Example: plist(param('win', specwin('Hannning', 100)))
0101 %
0102 %   'waveform' - construct an AO from a waveform description. Here you need
0103 %                to specify additional parameters 'fs' and 'nsecs', and also,
0104 %                for the following waveform types:
0105 %                'sine wave'      - 'f', 'phi'
0106 %                'noise'          - 'type' (can be 'Normal' or 'Uniform')
0107 %                'chirp'          - 'f0', 'f1', 't1'      (help chirp)
0108 %                'Gaussian pulse' - 'f0', 'bw'            (help gauspuls)
0109 %                'Square wave'    - 'f', 'duty'           (help square)
0110 %                'Sawtooth'       - 'f', 'width'          (help sawtooth)
0111 %
0112 %   'Hostname' - construct an AO by retrieving it from an LTPDA repository
0113 %                specified by the given hostname. Only those objects which
0114 %                are AOs are returned.
0115 %                Additional parameters:
0116 %                'Database'   - The database name [default: 'ltpda']
0117 %                'ID'         - A vector of object IDs.
0118 %
0119 %   'Plist'    - construct from a plist. The value passed should be a plist
0120 %                object.
0121 %
0122 %   Examples:
0123 %
0124 %   1) Normally distributed random noise time-series
0125 %
0126 %      p     = plist('waveform', 'noise', 'fs', 10, 'nsecs', 1000);
0127 %      rd10  = ao(p);
0128 %
0129 %
0130 %
0131 %     Indexing:
0132 %       b = a(1)            % where a is an array of analysis objects
0133 %       d = a.data;         % get the data object
0134 %       h = a.hist;         % get the history object
0135 %       d = a.data.x(1:20); % get a matrix of data values x;
0136 %
0137 % The following call returns a parameter list object that contains the
0138 % default parameter values:
0139 %
0140 % >> pl = ao(ao, 'Params')
0141 %
0142 % The following call returns a string that contains the routine CVS version:
0143 %
0144 % >> version = ao(ao,'Version')
0145 %
0146 % The following call returns a string that contains the routine category:
0147 %
0148 % >> category = ao(ao,'Category')
0149 %
0150 % See also tsdata, fsdata, xydata, cdata, xyzdata
0151 %
0152 % M Hewitson 30-01-07
0153 %
0154 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0155 
0156 %       a = ao('object.mat') - creates a new analysis object by loading the
0157 %                             analysis object from disk .
0158 
0159 ALGONAME = mfilename;
0160 VERSION  = '$Id: ao.m,v 1.81 2008/02/25 18:02:45 ingo Exp $';
0161 CATEGORY = 'Constructor';
0162 
0163 %%% Check if this is a special call: default parameter list, cvs-version,
0164 if  (nargin == 2 || nargin == 3) &&...
0165     isa(varargin{1}, 'ao') &&...
0166     ischar(varargin{2})
0167   if strcmp(varargin{2}, 'Params')
0168     if nargin == 2
0169       varargout{1} = getDefaultPlist();
0170     else
0171       varargout{1} = getDefaultPlist(varargin{3});
0172     end
0173     return
0174   elseif strcmp(varargin{2}, 'Version')
0175     varargout{1} = VERSION;
0176     return
0177   elseif strcmp(varargin{2}, 'Category')
0178     varargout{1} = CATEGORY;
0179     return
0180   end
0181 end
0182 
0183 
0184 % process input arguments
0185 args = [];
0186 k = 0;
0187 pls = [];
0188 for j=1:nargin
0189   if ~isempty(varargin{j})
0190     k = k + 1;
0191     if isa(varargin{j}, 'plist')
0192       pls = [pls varargin{j}];
0193     else
0194       args(k).val = varargin{j};
0195       args(k).n   = j;
0196     end
0197   end
0198 end
0199 
0200 % We could have multiple input plist objects. Combine them here.
0201 if isa(pls, 'plist')
0202   pl = combine(pls);
0203 else
0204   pl = [];
0205 end
0206 
0207 Nargs = length(args);
0208 if ~isempty(pl)
0209   args(Nargs+1).val = pl;
0210   args(Nargs+1).n   = j+1;
0211   Nargs = length(args);
0212 end
0213 
0214 %%%%%%%%%%%%%%%%%%%%   define parameter properties list   %%%%%%%%%%%%%%%%%%%%%
0215 
0216   function a = init()
0217     a.name        = 'None';
0218     a.data        = {};
0219     a.hist        = history(ALGONAME, VERSION);
0220     a.provenance  = provenance;
0221     a.description = '';
0222     a.mfile       = '';
0223     a.mfilename   = '';
0224     a.mdlfile     = '';
0225     a.mdlfilename = '';
0226     a.plist       = plist();
0227     a.version     = VERSION;
0228     a.created     = time;
0229     a = class(a, 'ao');
0230   end
0231 
0232 
0233 %%%%%%%%%%%%%%%%%%%%%%%%%   Create analysis object   %%%%%%%%%%%%%%%%%%%%%%%%%%
0234 
0235 %%%%%%%%%%   pl = ao()   %%%%%%%%%%
0236 if Nargs == 0
0237 
0238   varargout{1} = init();
0239 
0240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0241 %%%                              One Parameter                              %%%
0242 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0243 elseif Nargs == 1              % create ao with data
0244 
0245   %%%%%%%%%%   a1 = ao('foo.mat')   %%%%%%%%%%
0246   %%%%%%%%%%   a1 = ao('foo.xml')   %%%%%%%%%%
0247   if ischar(args(1).val)
0248 
0249     a = init();
0250 
0251     filename = args(1).val;
0252     [path, name, ext, vers] = fileparts(filename);
0253     switch ext
0254       case '.mat'
0255         a = load(filename);
0256         a = a.a;
0257         a.name = strcat(name, ext);
0258       case '.xml'
0259         root_node = xmlread(filename);
0260         a = ltpda_xmlread(root_node, 'ao');
0261       case {'.txt', '.dat'}
0262         a = aoFromFilenameAndPlist(a, args(1).val, plist(), VERSION, ALGONAME);
0263         a.name = strcat(name, ext);
0264       otherwise
0265         error('### Unknown file type.');
0266     end
0267     varargout{1} = a;
0268 
0269   %%%%%%%%%%   a1 = ao(ao)   %%%%%%%%%%
0270   elseif isa(args(1).val, 'ao')
0271     varargout{1} = args(1).val;
0272 
0273   %%%%%%%%%%   a1 = ao(struct)   %%%%%%%%%%
0274   % create from struct
0275   elseif isstruct(args(1).val)
0276     a       = init();
0277     astruct = args(1).val;
0278     a.name  = astruct.name;
0279     data    = astruct.data;
0280 
0281     if isstruct(data)
0282       if isfield(data, {'t', 'x'})
0283         data = tsdata(data);
0284       elseif isfield(data, {'f', 'xx'})
0285         data = fsdata(data);
0286       elseif isfield(data, {'vals'})
0287         data = cdata(data);
0288       elseif isfield(data, {'x', 'y'})
0289         data = xydata(data);
0290       elseif isfield(data, {'x', 'y', 'z'})
0291         data = xyzdata(data);
0292       else
0293         error('### Unknown data type in input structure.');
0294       end
0295     end
0296 
0297     a.data = data;
0298     hist   = astruct.hist;
0299     if isstruct(hist)
0300       hist = history(hist);
0301     end
0302     a.hist = hist;
0303     prov = astruct.provenance;
0304     if isstruct(prov)
0305       prov = provenance(prov);
0306     end
0307 
0308     a.provenance  = prov;
0309     a.description = astruct.description;
0310     a.mfile       = astruct.mfile;
0311     a.mfilename   = astruct.mfilename;
0312     a.mdlfile     = astruct.mdlfile;
0313     a.mdlfilename = astruct.mdlfilename;
0314     a.plist       = astruct.plist;
0315     a.version     = astruct.version;
0316     created       = astruct.created;
0317     if isstruct(created)
0318       created = time(created);
0319     end
0320     a.created     = created;
0321     varargout{1}  = a;
0322 
0323   %%%%%%%%%%   a1 = ao(1)   %%%%%%%%%%
0324   % create from constant
0325   elseif isnumeric(args(1).val)
0326 
0327     a      = init();
0328     a.name = 'const';
0329     a.data = cdata(args(1).val);
0330     a.hist = history(ALGONAME, VERSION, plist(param('vals', args(1).val)));
0331 
0332     varargout{1}  = a;
0333 
0334   %%%%%%%%%%   a1 = ao(plist)   %%%%%%%%%%
0335   % create data using plist
0336   elseif isa(args(1).val, 'plist')
0337 
0338     pl       = args(1).val;
0339     filename = find(pl, 'filename');
0340     fcn      = find(pl, 'fcn');
0341     vals     = find(pl, 'vals');
0342     tsfcn    = find(pl, 'tsfcn');
0343     fsfcn    = find(pl, 'fsfcn');
0344     win      = find(pl, 'win');
0345     waveform = find(pl, 'waveform');
0346     hostname = find(pl, 'hostname');
0347     ipl      = find(pl, 'Plist');
0348 
0349     a = init();
0350     a.plist = pl;
0351 
0352     if ~isempty(filename)
0353       % do filename constructor
0354       [path, name, ext, vers] = fileparts(filename);
0355       switch ext
0356         case '.mat'
0357           a = load(filename);
0358           varargout{1} = a.a;
0359         case '.xml'
0360           root_node = xmlread(filename);
0361           a = ltpda_xmlread(root_node, 'ao');
0362           varargout{1} = a;
0363         case {'.txt', '.dat'}
0364           ao_out = aoFromFilenameAndPlist(a, filename, pl, VERSION, ALGONAME);
0365           if nargout == 1
0366             varargout{1} = ao_out;
0367           elseif nargout == length(ao_out)
0368             for ii = 1:length(ao_out)
0369               varargout{ii} = ao_out(ii);
0370             end
0371           else
0372             warning ('### Too few output variables --> useing only the first.');
0373             varargout{1} = ao_out;
0374           end
0375         otherwise
0376           error('### Unknown file type.');
0377       end
0378 
0379     elseif ~isempty(fcn)
0380       % do function constructor
0381       varargout{1} = aoFromFcn(a, pl, VERSION, ALGONAME);
0382 
0383     elseif ~isempty(vals)
0384       % do vals constructor
0385       varargout{1} = aoFromVals(a, vals, VERSION, ALGONAME);
0386     elseif ~isempty(tsfcn)
0387       % do tsfcn constructor
0388       varargout{1} = aoFromTSfcn(a, pl, VERSION, ALGONAME);
0389     elseif ~isempty(fsfcn)
0390       % do fsfcn constructor
0391       varargout{1} = aoFromFSfcn(a, pl, VERSION, ALGONAME);
0392     elseif ~isempty(win)
0393       % do win constructor
0394       varargout{1} = aoFromSpecWin(a, win, VERSION, ALGONAME);
0395     elseif ~isempty(waveform)
0396       % do waveform constructor
0397       varargout{1} = aoFromWaveform(a, pl, VERSION, ALGONAME);
0398     elseif ~isempty(hostname)
0399       % do hostname constructor
0400       varargout{1} = aoFromRepository(a, pl, VERSION, ALGONAME);
0401     elseif ~isempty(ipl)
0402       % do plist constructor
0403       varargout{1} = ao(ipl);
0404     else
0405       error('### Unknown AO constructor method.');
0406     end
0407 
0408   %%%%%%%%%%   a1 = ao(specwin)   %%%%%%%%%%
0409   % create from spectral window
0410   elseif isa(args(1).val, 'specwin')
0411     a = init();
0412     varargout{1} = aoFromSpecWin(a, args(1).val, VERSION, ALGONAME);
0413 
0414   %%%%%%%%%%   a1 = ao(cdata)    %%%%%%%%%%
0415   %%%%%%%%%%   a1 = ao(fsdata)   %%%%%%%%%%
0416   %%%%%%%%%%   a1 = ao(tsdata)   %%%%%%%%%%
0417   %%%%%%%%%%   a1 = ao(xydata)   %%%%%%%%%%
0418   % create from data object
0419   else
0420     a = init();
0421     data          = args(1).val;
0422     a.name        = 'None';
0423     a.data        = data;
0424     a.hist        = history(ALGONAME, VERSION);
0425 
0426     if ~isa(a.data, 'tsdata') &&...
0427        ~isa(a.data, 'fsdata') &&...
0428        ~isa(a.data, 'cdata')  &&...
0429        ~isa(a.data, 'xydata')  &&...
0430        ~isa(a.data, 'xyzdata')
0431       error('### unknown data object.')
0432     end
0433     varargout{1} = a;
0434   end
0435 
0436 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0437 %%%                              Two Parameter                              %%%
0438 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0439 
0440 elseif Nargs == 2
0441 
0442   %%%%%%%%%%   Database   %%%%%%%%%%
0443   if isa(varargin{1}, 'database')
0444     varargout{1} = retrieve(varargin{1}, varargin{2:end});
0445 
0446   %%%%%%%%%%%   ao('foo.txt', pl)   %%%%%%%%%%
0447   elseif ischar(args(1).val) && isa(args(2).val, 'plist')
0448 
0449     a = init();
0450 
0451     ao_out = aoFromFilenameAndPlist(a, args(1).val, args(2).val, VERSION, ALGONAME);
0452 
0453     for ii = numel(ao_out)
0454       ao_out(ii).plist = args(2).val;
0455       ao_out(ii).name = args(1).val;
0456     end
0457 
0458     if nargout == 1
0459       varargout{1} = ao_out;
0460     elseif nargout == length(ao_out)
0461       for ii = 1:length(ao_out)
0462         varargout{ii} = ao_out(ii);
0463       end
0464     else
0465       warning ('### Too few output variables --> useing only the first.');
0466       varargout{1} = ao_out;
0467     end
0468 
0469   %%%%%%%%%%%   ao(data-object, history-object)   %%%%%%%%%%
0470   else
0471 
0472     a = init();
0473 
0474     a.data        = args(1).val;
0475     a.hist        = args(2).val; %history(ALGONAME, VERSION, [], varargin{2});
0476 
0477     if ~isa(a.data, 'tsdata') &&...
0478         ~isa(a.data, 'fsdata') &&...
0479         ~isa(a.data, 'cdata')  &&...
0480         ~isa(a.data, 'xydata')
0481       error('### unknown data object.')
0482     end
0483     if ~isa(a.hist, 'history')
0484       error('### unknown history object.')
0485     end
0486 
0487     varargout{1} = a;
0488 
0489   end
0490 
0491 
0492 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0493 %%%                             Nine Parameter                              %%%
0494 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0495 %  full constructor - all fields
0496 elseif Nargs == 9
0497 
0498   a = init();
0499   a.name        = args(1).val;
0500   a.data        = args(2).val;
0501   a.hist        = args(3).val;
0502   a.provenance  = args(4).val;
0503   a.description = args(5).val;
0504   a.mfile       = args(6).val;
0505   a.mfilename   = args(7).val;
0506   a.mdlfile     = args(8).val;
0507   a.mdlfilename = args(9).val;
0508   varargout{1}  = a;
0509 
0510 else
0511   error('### Unknown number of constructor arguments.');
0512 end
0513 
0514 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0515 %
0516 % FUNCTION:    aoFromRepository
0517 %
0518 % DESCRIPTION: Construct an ao from a repository
0519 %
0520 % CALL:        aos = aoFromRepository(a, pl, VERSION, ALGONAME)
0521 %
0522 % PARAMETER:   a:        Initialised analysis object
0523 %              pl:       Parameter list object
0524 %              VERSION:  cvs version string
0525 %              ALGONAME: The m-file name (use the mfilename command)
0526 %
0527 % HISTORY:     07-05-2007 Hewitson
0528 %              Creation
0529 %
0530 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0531 function aos = aoFromRepository(a, pl, VERSION, ALGONAME)
0532 
0533   dpl = getDefaultPlist('From Repository');
0534   pl  = combine(pl, dpl);
0535 
0536   % Get parameters
0537   conn = find(pl, 'conn');
0538   hostname = find(pl, 'hostname');
0539   database = find(pl, 'database');
0540   ids      = find(pl, 'id');
0541   
0542   % do we have a connection?
0543   closeConn = 0;
0544   if isempty(conn)
0545     closeConn = 1;
0546     % Connect to repository
0547     conn = mysql_connect(hostname, database);
0548   end
0549   if ~isa(conn, 'database')
0550     error('### connection failed.');
0551   end
0552   
0553   % Get each ID
0554   Nids = length(ids);
0555   aos  = [];
0556   for kk=1:Nids
0557 
0558     %---- This id
0559     id = ids(kk);
0560     disp(sprintf('  - retrieving ID %d', id));
0561 
0562     %---- check ID object type
0563     tt = mysql_getObjType(conn, id);
0564     %---- If this is an AO
0565     if strcmp(tt, mfilename)
0566       %---- call database constructor
0567       a = ltpda_obj_retrieve(conn, id);
0568       %---- Add history
0569 
0570       % make a new history object
0571       %  - remove connection object from plist first
0572       h = history(ALGONAME, VERSION, remove(pl, 'conn'), a.hist);
0573 
0574       % set this to the AO
0575       a = setnh(a, 'hist', h);
0576 
0577       %---- Add to output array
0578       aos = [aos a];
0579     else
0580       warning('    !skipping ID %d, type %s', id, tt);
0581     end
0582 
0583   end
0584 
0585   % close connection
0586   if closeConn
0587     close(conn);
0588   end
0589 end
0590 
0591 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0592 %
0593 % FUNCTION:    aoFromVals
0594 %
0595 % DESCRIPTION: Construct an ao from a value set
0596 %
0597 % CALL:        a = aoFromVals(a, vals, VERSION, ALGONAME)
0598 %
0599 % PARAMETER:   a:        Initialised analysis object
0600 %              vals:     Constant values
0601 %              VERSION:  cvs version string
0602 %              ALGONAME: The m-file name (use the mfilename command)
0603 %
0604 % HISTORY:     07-05-2007 Hewitson
0605 %              Creation
0606 %
0607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0608 function a = aoFromVals(a, vals, VERSION, ALGONAME)
0609 
0610   if ischar(vals)
0611     try
0612       vals = eval(vals);
0613     catch
0614       error('Could not convert char array to numeric array.');
0615     end
0616   end
0617 
0618   % Make a cdata object
0619   ts = cdata(plist(param('vals', vals)));
0620   ts = set(ts, 'name', 'Data');
0621 
0622   % Make an analysis object
0623   a.name = 'Data';
0624   a.data = ts;
0625   a.hist = history(ALGONAME, VERSION, plist(param('vals', vals)));
0626 end
0627 
0628 
0629 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0630 %
0631 % FUNCTION:    aoFromWaveform
0632 %
0633 % DESCRIPTION: Construct an ao from a waveform
0634 %
0635 % CALL:        a = aoFromWaveform(a, pl, VERSION, ALGONAME)
0636 %
0637 % PARAMETER:   a:        Initialised analysis object
0638 %              pl:       Parameter list object
0639 %              VERSION:  cvs version string
0640 %              ALGONAME: The m-file name (use the mfilename command)
0641 %
0642 % HISTORY:     07-05-2007 Hewitson
0643 %              Creation
0644 %
0645 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0646 function a = aoFromWaveform(a, pl, VERSION, ALGONAME)
0647 
0648   nsecs  = find(pl, 'nsecs');
0649   fs     = find(pl, 'fs');
0650   t0     = find(pl, 't0');
0651   if isempty(t0)
0652     t0 = time(0);
0653   end
0654   
0655   waveform = find(pl, 'waveform');
0656   switch waveform
0657     %------------ Sine Wave
0658     case 'sine wave'
0659       freq = find(pl, 'f');
0660       phi  = find(pl, 'phi');
0661       if isempty(freq)
0662         freq = 1;
0663       end
0664       if isempty(phi)
0665         phi = 0;
0666       end
0667       tsfcn = sprintf('sin(2*pi*%g*t + %g*pi/180)', freq, phi);
0668       %------------ Noise
0669     case 'noise'
0670       ntype = find(pl, 'type');
0671       if isempty(ntype)
0672         ntype = 'Normal';
0673       end
0674       switch ntype
0675         case 'Normal'
0676           tsfcn = 'randn(size(t))';
0677         case 'Uniform'
0678           tsfcn = 'rand(size(t))';
0679       end
0680       %------------ Chirp
0681     case 'chirp'
0682       f0  = find(pl, 'f0');
0683       fe  = find(pl, 'f1');
0684       te  = find(pl, 't1');
0685       if isempty(f0)
0686         f0 = 0;
0687       end
0688       if isempty(fe)
0689         fe = fs/2;
0690       end
0691       if isempty(te)
0692         te = nsecs;
0693       end
0694       tsfcn = sprintf('chirp(t,%g,%g,%g)', f0, fe, te);
0695       %------------ Gaussian pulse
0696     case 'Gaussian pulse'
0697       fc  = find(pl, 'f0');
0698       bw  = find(pl, 'bw');
0699       if isempty(fc)
0700         fc = 1;
0701       end
0702       if isempty(bw)
0703         bw = fs/2;
0704       end
0705       tsfcn = sprintf('gauspuls(t,%g,%g)', fc, bw);
0706     case 'Square wave'
0707       freq = find(pl, 'f');
0708       duty = find(pl, 'duty');
0709       if isempty(freq)
0710         freq = 1;
0711       end
0712       if isempty(duty)
0713         duty = 50;
0714       end
0715       tsfcn = sprintf('square(2*pi*%g*t,%g)', freq, duty);
0716     case 'Sawtooth'
0717       freq  = find(pl, 'f');
0718       width = find(pl, 'width');
0719       if isempty(freq)
0720         freq = 1;
0721       end
0722       if isempty(width)
0723         width = 0.5;
0724       end
0725       tsfcn = sprintf('sawtooth(2*pi*%g*t,%g)', freq, width);
0726   end
0727 
0728 
0729   % construct tsdata
0730   t = linspace(0, nsecs-1/fs, nsecs*fs);
0731   % make y data
0732   y = eval([tsfcn ';']);
0733 
0734   ts = tsdata(t,y);
0735   ts = set(ts, 'name', tsfcn);
0736   ts = set(ts, 'xunits', 's');
0737   ts = set(ts, 'yunits', 'V');
0738   ts = set(ts, 't0', t0);
0739 
0740   % Make an analysis object
0741   a.name = waveform;
0742   a.data = ts;
0743   a.hist = history(ALGONAME, VERSION, pl);
0744 end
0745 
0746 
0747 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0748 %
0749 % FUNCTION:    aoFromTSfcn
0750 %
0751 % DESCRIPTION: Construct an ao from a ts-function string
0752 %
0753 % CALL:        a = aoFromTSfcn(a, pl, VERSION, ALGONAME)
0754 %
0755 % PARAMETER:   a:        Initialised analysis object
0756 %              pl:       Parameter list object
0757 %              VERSION:  cvs version string
0758 %              ALGONAME: The m-file name (use the mfilename command)
0759 %
0760 % HISTORY:     07-05-2007 Hewitson
0761 %              Creation
0762 %
0763 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0764 function a = aoFromTSfcn(a, pl, VERSION, ALGONAME)
0765 
0766   nsecs       = find(pl, 'nsecs');
0767   fs          = find(pl, 'fs');
0768   fcn         = find(pl, 'tsfcn');
0769   randn_state = find(pl, 'rand_state');
0770   t0          = find(pl, 't0');
0771   if isempty(t0)
0772     t0 = time(0);
0773   end
0774 
0775   % construct tsdata
0776   t = linspace(0, nsecs-1/fs, nsecs*fs);
0777 
0778   % make y data
0779 
0780   % If the randn state is in the parameter list then set the randn function to
0781   % this sate
0782   if ~isempty(randn_state)
0783     randn('state',randn_state);
0784   else % Store the state of the random function in the parameter list
0785     randn_state = randn('state');
0786     pl = append(pl , 'rand_state', randn_state);
0787   end
0788 
0789   y = eval([fcn ';']);
0790 
0791   ts = tsdata(t,y);
0792   ts = set(ts, 'name', fcn);
0793   ts = set(ts, 'xunits', 's');
0794   ts = set(ts, 'yunits', 'V');
0795   ts = set(ts, 't0', t0);
0796   
0797   % Make an analysis object
0798   a.name = 'TSfcn';
0799   a.data = ts;
0800   a.hist = history(ALGONAME, VERSION, pl);
0801 end
0802 
0803 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0804 %
0805 % FUNCTION:    aoFromFSfcn
0806 %
0807 % DESCRIPTION: Construct an ao from a fs-function string
0808 %
0809 % CALL:        a = aoFromFSfcn(a, pl, VERSION, ALGONAME)
0810 %
0811 % PARAMETER:   a:        Initialised analysis object
0812 %              pl:       Parameter list object
0813 %              VERSION:  cvs version string
0814 %              ALGONAME: The m-file name (use the mfilename command)
0815 %
0816 % HISTORY:     07-05-2007 Hewitson
0817 %              Creation
0818 %
0819 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0820 function a = aoFromFSfcn(a, pl, VERSION, ALGONAME)
0821 
0822   dpl = getDefaultPlist('Frequency-series Function');
0823   pl  = combine(pl, dpl);
0824   f   = find(pl, 'f');
0825   if isempty(f)
0826     disp('--- generating f')
0827     f1 = find(pl, 'f1');
0828     f2 = find(pl, 'f2');
0829     nf = find(pl, 'nf');
0830     scale = find(pl, 'scale');
0831     switch scale
0832       case 'log'
0833         f = logspace(log10(f1), log10(f2), nf);
0834       case 'lin'
0835         f = linspace(f1, f2, nf);
0836       otherwise
0837         error('### Unknown frequency scale specified');
0838     end
0839   end
0840 
0841   % Get the function
0842   fcn  = find(pl, 'fsfcn');
0843 
0844   % make y data
0845   y = eval([fcn ';']);
0846 
0847   fs = fsdata(f,y);
0848   fs = set(fs, 'name', fcn);
0849   fs = set(fs, 'xunits', 'Hz');
0850   fs = set(fs, 'yunits', 'Arb');
0851 
0852   % Make an analysis object
0853   a.name = 'FSfcn';
0854   a.data = fs;
0855   a.hist = history(ALGONAME, VERSION, pl);
0856 end
0857 
0858 
0859 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0860 %
0861 % FUNCTION:    aoFromFcn
0862 %
0863 % DESCRIPTION: Construct an ao from a function string
0864 %
0865 % CALL:        a = aoFromFcn(a, pl, VERSION, ALGONAME)
0866 %
0867 % PARAMETER:   a:        Initialised analysis object
0868 %              pl:       Parameter list object
0869 %              VERSION:  cvs version string
0870 %              ALGONAME: The m-file name (use the mfilename command)
0871 %
0872 % HISTORY:     07-05-2007 Hewitson
0873 %              Creation
0874 %
0875 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0876 function a = aoFromFcn(a, pl, VERSION, ALGONAME)
0877 
0878   fcn = find(pl, 'fcn');
0879 
0880   % Make a cdata object
0881   ts = cdata(plist(param('fcn', fcn)));
0882   ts = set(ts, 'name', fcn);
0883 
0884   % Make an analysis object
0885   a.name = fcn;
0886   a.data = ts;
0887   a.hist = history(ALGONAME, VERSION, pl);
0888 end
0889 
0890 
0891 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0892 %
0893 % FUNCTION:    aoFromFilenameAndPlist
0894 %
0895 % DESCRIPTION: Construct an ao from filename AND parameter list
0896 %
0897 % CALL:        a = aoFromFilenameAndPlist(init_ao, file_name, pl, VERSION, ALGONAME)
0898 %
0899 % PARAMETER:   init_ao:   Initialised analysis object
0900 %              file_name: File name
0901 %              pl:        Parameter list object
0902 %              VERSION:   cvs version string
0903 %              ALGONAME:  The m-file name (use the mfilename command)
0904 %
0905 % HISTORY:     07-05-2007 Hewitson
0906 %              Creation
0907 %
0908 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0909 function a = aoFromFilenameAndPlist(init_ao, file_name, pl, VERSION, ALGONAME)
0910 
0911   a = [];
0912 
0913   [pathstr, f_name, ext] = fileparts(file_name);
0914 
0915   %%%%%%%%%%   Define default parameter list   %%%%%%%%%%
0916   pl_default = plist('columns',      [1 2],    ...
0917                      'num_columns',   10,      ...
0918                      'type',         'tsdata', ...
0919                      'use_fs',       '',       ...
0920                      'comment_char', '%',      ...
0921                      'xunits',       'sec',    ...
0922                      'yunits',       'V');
0923   pl = combine(pl, pl_default);
0924 
0925   pl = pset(pl, param('filename', [f_name ext]));
0926   pl = pset(pl, param('filepath', pathstr));
0927 
0928   data_type    = find (pl, 'type');
0929   columns      = find (pl, 'columns');
0930   num_columns  = find (pl, 'num_columns');
0931   comment_char = find (pl, 'comment_char');
0932   use_fs       = find (pl, 'use_fs');
0933   xunits       = find (pl, 'xunits');
0934   yunits       = find (pl, 'yunits');
0935   t0           = find (pl, 't0');
0936   
0937   %%%%%%%%%%   read file   %%%%%%%%%%
0938   [fid,msg] = fopen (file_name, 'r');
0939   if (fid < 0)
0940     error ('### can not open file: %s \n\n### error msg:',file_name, msg);
0941   end
0942 
0943   %%%%%%%%%% create scan format: '%f %f %f %f %f'   %%%%%%%%%%
0944   scan_format = [];
0945   for ii=1:num_columns
0946     scan_format = [scan_format '%f '];
0947   end
0948   scan_format = scan_format(1:end-1); % remove the last whitespace
0949 
0950   %%%%%%%%%%   scan the file   %%%%%%%%%%
0951   raw_data = textscan( fid, scan_format,             ...
0952                       'commentStyle',  comment_char, ...
0953                       'CollectOutput', 1);
0954   f_data = raw_data{1};
0955 
0956   if isempty(f_data)
0957     error([char(10) '### There are no data. ' ...
0958                     'Did you use the right comment character?'            char(10) ...
0959                     '### The current comment character is: ' comment_char char(10) ...
0960                     '### Use a parameter list with the parameter:'        char(10) ...
0961                     '### plist(''comment_char'', ''%'')']);
0962   end
0963 
0964   fclose(fid);
0965 
0966   %%%%%%%%%%   Create for each column pair the data object   %%%%%%%%%%
0967   if isempty(use_fs)
0968 
0969     %%%%%%%%%%   The numbers in columns must be straight   %%%%%%%%%%
0970     if mod(length(columns),2) ~= 0
0971       error('### the numbers in columns must be straight');
0972     end
0973 
0974     for lauf = 1:length(columns)/2
0975 
0976       data_x_axes = f_data(:, columns(lauf*2-1));
0977       data_y_axes = f_data(:, columns(lauf*2));
0978 
0979       %% create data object corresponding to the parameter list
0980       ao_data = [];
0981       switch data_type
0982         case 'tsdata'
0983           ao_data = tsdata( data_x_axes, data_y_axes);
0984         case 'fsdata'
0985           ao_data = fsdata( data_x_axes, data_y_axes);
0986         case 'cdata'
0987           error ('### please code me up')
0988         case 'xydata'
0989           ao_data = xydata( data_x_axes, data_y_axes);
0990         otherwise
0991           error('### unknown data type ''%s''', data_type);
0992       end
0993       ao_data.name = sprintf('f_name_%02d', lauf);
0994       ao_data.xunits = xunits;
0995       ao_data.yunits = yunits;
0996 
0997       aa = init_ao;
0998 
0999       aa.name = sprintf('f_name_%02d', lauf);
1000       aa.data = ao_data;
1001       aa.hist = history(ALGONAME, VERSION, pl);
1002 
1003       %% Set the description fron the parameter list or from the file
1004       description_pl = find(pl, 'description');
1005       if ~isempty(description_pl)
1006         aa.description = description_pl;
1007       end
1008 
1009       a = [a aa];
1010 
1011     end
1012 
1013   %%%%%%%%%%   Create for each column AND fs a data object   %%%%%%%%%%
1014   else % isempty(use_fs)
1015 
1016     for lauf = 1:length(columns)
1017 
1018       data_y_axes = f_data(:, columns(lauf));
1019 
1020       %% create data object corresponding to the parameter list
1021       ao_data = [];
1022       switch data_type
1023         case 'tsdata'
1024           ao_data = tsdata(data_y_axes, use_fs);
1025         case 'fsdata'
1026           ao_data = fsdata(data_y_axes, use_fs);
1027         case 'cdata'
1028           error ('### please code me up')
1029         case 'xydata'
1030           error ('### please code me up')
1031         otherwise
1032           error('### unknown data type ''%s''', data_type);
1033       end
1034       ao_data.name = sprintf('f_name_%02d', lauf);
1035       ao_data.xunits = xunits;
1036       ao_data.yunits = yunits;
1037 
1038       aa      = init_ao;
1039       aa.name = sprintf('f_name_%02d', lauf);
1040       aa.data = ao_data;
1041       aa.hist = history(ALGONAME, VERSION, pl);
1042 
1043       %% Set the description fron the parameter list or from the file
1044       description_pl = find(pl, 'description');
1045       if ~isempty(description_pl)
1046         aa.description = description_pl;
1047       end
1048 
1049       a = [a aa];
1050 
1051     end
1052 
1053   end
1054 
1055   %%%%%%%%%%   set fields of the data object from the parameter list   %%%%%%%%%%
1056   for ii = 1:length(a)
1057     fields = fieldnames(a(ii).data);
1058     for jj = 1:length(pl.params)
1059       parameter = lower(pl.params(jj));
1060       if ismember(parameter.key, upper(fields))           
1061         if iscell(parameter.val)          
1062           if length(parameter.val) > 1
1063             if length(parameter.val) ~= length(a)
1064               warning([sprintf('The values of the key ''%s'' ', parameter.key) ...
1065                                'have not the same length as the lentgh of '    ...
1066                                'the output. Using the first value!']);
1067               a(ii).data.(lower(parameter.key)) = parameter.val{1};
1068             else
1069               a(ii).data.(lower(parameter.key)) = parameter.val{ii};
1070             end
1071           else
1072             a(ii).data.(lower(parameter.key)) = parameter.val{1};
1073           end
1074         else                    
1075           a(ii).data.(lower(parameter.key)) = parameter.val;
1076         end
1077 
1078       end % is parameter key member of the data object
1079     end % for-loop over all parameter
1080   end % for-loop over all ao's
1081 end
1082 
1083 
1084 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1085 %
1086 % FUNCTION:    aoFromSpecWin
1087 %
1088 % DESCRIPTION: Construct an ao from a Spectral window
1089 %
1090 % CALL:        a = aoFromSpecWin(a, win, VERSION, ALGONAME)
1091 %
1092 % PARAMETER:   a:        Initialised analysis object
1093 %              win:      Spectral window object
1094 %              VERSION:  cvs version string
1095 %              ALGONAME: The m-file name (use the mfilename command)
1096 %
1097 % HISTORY:     07-05-2007 Hewitson
1098 %              Creation
1099 %
1100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1101 function a = aoFromSpecWin(a, win, VERSION, ALGONAME)
1102 
1103   % Make a cdata object
1104   ts = cdata(win.win);
1105   ts = set(ts, 'name', win.name);
1106 
1107   % Make an analysis object
1108   a.name = win.name;
1109   a.data = ts;
1110   a.hist = history(ALGONAME, VERSION, plist(param('win', win)));
1111 end
1112 
1113 
1114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1115 %
1116 % FUNCTION:    getDefaultPlist
1117 %
1118 % DESCRIPTION: Default Parameter Lists
1119 %
1120 % CALL:        out = getDefaultPlist(set-string)
1121 %
1122 % PARAMETER:   set-string: A string which defines the default parameter list.
1123 %
1124 % HISTORY:     07-05-2007 Hewitson
1125 %              Creation
1126 %
1127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1128 function out = getDefaultPlist(varargin)
1129 
1130   % list of available parameter sets
1131   sets = {'From XML file', 'From ASCII file',...
1132     'Function', 'Values',...
1133     'Time-series Function', 'Frequency-series Function', ...
1134     'From Window', 'Waveform', 'From Repository',...
1135     'From Plist'};
1136 
1137   if nargin == 0
1138     out = sets;
1139     return
1140   end
1141 
1142   set = varargin{1};
1143 
1144   switch set
1145     case 'From Repository'
1146       out = plist('hostname', 'localhost', 'database', 'ltpda', 'ID', []);
1147     case 'From XML file'
1148       out = plist('filename', 'foo.xml');
1149     case 'From ASCII file'
1150       out = plist('filename', 'foo.txt',...
1151         'type', 'tsdata',...
1152         'columns', [1 2],...
1153         'num_columns', 10,...
1154         't0', time(0),...
1155         'comment_char', '%');
1156     case 'Function'
1157       out = plist('fcn', 'randn(100,1)');
1158     case 'Values'
1159       out = plist('vals', [1 2 3]);
1160     case 'Time-series Function'
1161       out = plist('tsfcn', 'randn(size(t))', 'fs', 10, 'nsecs', 100, 't0', time(0));
1162     case 'Frequency-series Function'
1163       out = plist('fsfcn', '1./f', 'f1', 1e-9, 'f2', 100, 'nf', 1000, 'scale', 'log', 'f', []);
1164     case 'From Window'
1165       out = plist('win', specwin('Hanning', 100));
1166     case 'From Plist'
1167       out = plist('Plist', plist);
1168     case 'Waveform'
1169       out = plist('waveform', 'sine wave',...
1170         'f', 1.23,...
1171         'phi', 0,...
1172         'fs', 10,...
1173         'nsecs', 10,...
1174         't0', time(0));
1175     otherwise
1176       out = plist();
1177   end
1178 
1179 end
1180 % END
1181 
1182 end

Generated on Tue 26-Feb-2008 10:52:52 by m2html © 2003