Working with LTPDA objects


The use of LTPDA objects requires some understanding of the nature of objects as implemented in MATLAB.

For full details of objects in MATLAB, refer to MATLAB Classes and Object-Oriented Programming. For convenience, the most important aspects in the context of LTPDA are reviewed below.

Calling object methods

Each class in LTPDA has a set of methods (functions) which can operate/act on instances of the class (objects). For example, the AO class has a method psd which can compute the Power Spectral Density estimate of a time-series AO.

To see which methods a particular class has, use the methods command. For example,

      >> methods('ao')
  

To call a method on an object, obj.method, or, method(obj). For example,

      >> b = a.psd
  
or
      >> b = psd(a)
  
Additional arguments can be passed to the method (a plist, for example), as follows:
      >> b = a.psd(pl)
  
or
      >> b = psd(a, pl)
  


In order to pass multiple objects to a method, you must use the form

      >> b = psd(a1, a2, pl)
  


Some methods can behave as modifiers which means that the object which the method acts on is modified. To modify an object, just give no output. If we start with a time-series AO then modify it with the psd method,

      >> a = ao(1:100, randn(100,1), 10)
      >> a
       M:   running ao/display
      ----------- ao 01: a -----------
      
             name:  None
             data: (0,0.840375529753905) (0.1,-0.88803208232901) (0.2,0.100092833139322) (0.3,-0.544528929990548) (0.4,0.303520794649354) ...
                   -------- tsdata 01 ------------
              
                       fs:  10
                        x:  [100 1], double
                        y:  [100 1], double
                       dx:  [0 0], double
                       dy:  [0 0], double
                   xunits:  [s]
                   yunits:  []
                    nsecs:  10
                       t0:  1970-01-01 00:00:01.000
                   -------------------------------
              
             hist:  ao / ao / SId: fromVals ... -->$Id: ao .... S
          mdlfile:  empty
      description:  
             UUID:  8cffab46-61f0-494a-af03-eb310aa76114
      --------------------------------
  

Then call the psd method:
      >> a.psd
       M:   running ao/psd
       M:   running ao/len
       M:   running ao/len
       M:   running ao/display
      ----------- ao 01: PSD(a) -----------
 
             name:  PSD(a)
             data: (0,0.117412356146407) (0.1,0.179893990497347) (0.2,0.173957816470448) (0.3,0.245076068355785) (0.4,0.213036543621994) ...
                   ----------- fsdata 01 -----------
              
                       fs:  10
                        x:  [51 1], double
                        y:  [51 1], double
                       dx:  [0 0], double
                       dy:  [0 0], double
                   xunits:  [Hz]
                   yunits:  [Hz^(-1)]
                       t0:  1970-01-01 00:00:01.000
                     navs:  1
                   ---------------------------------
              
             hist:  ao / psd / SId: psd.m,v 1.52 2009/09/05 05:57:32 mauro Exp S
          mdlfile:  empty
      description:  
             UUID:  0d2395cd-22af-4645-a94c-69fa32c15982
      -------------------------------------
  

then the object a is converted to a frequency-series AO.


This modifier behaviour only works with certain methods, in particular, methods requiring more than one input object will not behave as modifiers.


Setting object properties

All object properties must be set using the appropriate setter method. For example, to set the name of a IIR filter object,

      >> ii = miir();
      >> ii.setName('My Filter');
  

Reading the value of a property is achieved by:

      >> ii.name

      ans =

      My Filter
  


Copying objects


Since all objects in LTPDA are handle objects, creating copies of objects needs to be done differently than in standard MATLAB. For example,

      >> a = ao();
      >> b = a;
  
in this case, the variable b is a copy of the handle a, not a copy of the object pointed too by the handle a. To see how this behaves,
      >> a = ao();
      >> b = a;
      >> b.setName('My Name');
      >> a.name

      ans =

      My Name
  

Copying the object can be achieved using the copy constructor:

      >> a = ao();
      >> b = ao(a);
      >> b.setName('My Name');
      >> a.name

      ans =

      none
  

In this case, the variable b points to a new distinct copy of the object pointed to by a.

Exploring objects

A browsing tool is provided on purpose to enable LTPDA objects exploring.

See the LTPDA Objects Explorer GUI documentation.



©LTP Team