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 (via a plist, for example), as follows:
      >> b = a.psd(plist('scale', 'PSD'))
  
or
      >> pl = plist('scale', 'PSD');
      >> 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), plist('type', 'tsdata'));
      M:     constructing from X and Y values and frequencies.
      >> a
      ----------- ao 01: a -----------
 
             name: ''
             data: (1,-0.356403360618887) (2,-0.431691783711256) (3,0.779328180381919) (4,0.816324576608273) (5,1.14830402609895) ...
                   -------- tsdata [x, y] --------
              
                        x:  [100 1], double
                        y:  [100 1], double
                       dx:  [0 0], double
                       dy:  [0 0], double
                   xunits:  [s]
                   yunits:  
                        fs:  1
                     nsecs:  100
                        t0:  1970-01-01 00:00:00.000 UTC
                   -------------------------------
              
             hist: ao / ao / 0fdb45fcdecae9b31415a1e452a9dd292856b644
      description: 
             UUID: e9d8bfdd-d01a-4f16-aefa-dc6c67b5d075
      --------------------------------
  

Then call the psd method:
      >> a.psd
      >> a.psd
      M:     using default Nfft of 100
      M:     reset window to BH92(100)
      M:     using default overlap of 66.1%
      ----------- ao 01: PSD(a) -----------
 
             name: PSD(a)
             data: (0,0.292599665179019) (0.01,0.229144695170146) (0.02,0.00474763264361868) (0.03,0.0438531813570101) (0.04,0.258565926012549) ...
                   -------- fsdata [x, y] --------
              
                        x:  [51 1], double
                        y:  [51 1], double
                       dx:  [0 0], double
                       dy:  [0 0], double
                   xunits:  [Hz]
                   yunits:  [Hz^(-1)]
                     enbw:  0.0200435
                       fs:  1
                       t0:  1970-01-01 00:00:01.000 UTC
                     navs:  1
                   -------------------------------
                    
             hist: ao / psd / 0fdb45fcdecae9b31415a1e452a9dd292856b644
      description: 
             UUID: 14ed0a0e-ba8b-4ebb-a50b-9563790ee0d5
      -------------------------------------
  

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 =
      ''
  

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



©LTP Team