Built-in Analysis Object Models


Introduction

Built-in Analysis Object models provide a convenient way to add parametric contructors to the AO class. This is best explained with an example.

One of the supplied built-in models is called 'whitenoise'. To see how to build this model, do

    >> help ao_model_whitenoise    

All AO model files are called ao_model_<model_name>.

In this case, the help shows:

 AO_MODEL_WHITENOISE constructs a known white-noise time-series
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
  DESCRIPTION: AO_MODEL_WHITENOISE constructs a known white-noise time-series.
 
  CALL:        a = ao(plist('built-in', 'whitenoise'), pl);
 
  INPUTS:
               pl - a parameter list of additional parameters (see below)
  
  PARAMETERS:  
               'sigma' - standard deviation of the noise. [default: 1]
               'nsecs' - number of seconds [s] of data. [default: 1]
               'fs'    - sample rate [Hz] for the white noise. [default: 10]
 
 
  VERSION:     $Id: builtin_models_ao_content.html,v 1.2 2009/02/18 13:14:23 hewitson Exp $
 
  HISTORY:     29-10-08 M Hewitson
                  Creation
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

To build this model, use the following constructor:

    a = ao(plist('built-in', 'whitenoise', 'sigma', 2, 'nsecs', 100, 'fs', 10))
----------- ao 01: WN -----------
 
       name:  WN
description:  
       data: (0,0.260207192213954) (0.1,-1.01369469442225) (0.2,-2.1763634062959) (0.3,1.00632778971068) (0.4,0.523897003913847) ...
             -------- tsdata 01 ------------
              
                 fs:  10
                  x:  [1000 1], double
                  y:  [1000 1], double
             xunits:  [s]
             yunits:  [V]
              nsecs:  100
                 t0:  1970-01-01 00:00:00.000
             -------------------------------
              
       hist:  ao / ao / $Id: builtin_models_ao_content.html,v 1.2 2009/02/18 13:14:23 hewitson Exp $-->$Id: builtin_models_ao_content.html,v 1.2 2009/02/18 13:14:23 hewitson Exp $
  mfilename:  
mdlfilename:  
---------------------------------

The special thing about this model, is that it always generates noise from the same seed, thus providing a reproducible data series.

Available models

To see a list of the currently available built-in models, you can use the ao class static method, getBuiltInModels:

  >> ao.getBuiltInModels

This returns a cell-array with two columns: the first columns contains the model names; the second column descriptions of the models.

You can also do

    >> ao(plist('built-in', ''))

Adding new models

The available AO models are determined by looking through a set of directories for all M-files with names like ao_model_<model_name>. The directories to be searched are specified in the LTPDA Preferences under the "models" section.

To add a new model of your own, do the following steps:

  1. Create a directory to store your AO model(s) in
  2. Add this directory to the list of AO model directories in the preferences
  3. Create a new M-file called ao_model_myModel (using an appropriate replacement for 'myModel')
  4. Edit the contents of the new model file using the supplied model files as an example

It is recommended to use the above 'whitenoise' model as an example when building your own models. The source code of that model is heavily commented. In particular, pay attention to the blocks of code between the EDIT tags. For example, the following code extract from ao_model_whitenoise.m is concerned with retrieving and processing the additional parameters for this model:

  %----- <EDIT>
  % Here we deal with the additional parameters of the model. In this case,
  % the sample rate of the resulting time-series, the number of seconds,
  % and the amplitude of the white-noise data series. When writing your own
  % model, you should include the necessary parameters here, together with
  % any checks on the possible parameter values.
  fs    = find(pl, 'fs');
  nsecs = find(pl, 'nsecs');
  sigma = find(pl, 'sigma');
  
  if isempty(fs)
    fs = 10;
  end
  if isempty(nsecs)
    nsecs = 1;
  end
  if isempty(sigma)
    sigma = 1;
  end
  %----- </EDIT>
  

To inspect the rest of the code for this model, just edit it:

  >> edit ao_model_whitenoise




©LTP Team