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
      M: running ao/display
      ----------- ao: a -----------
      
      name:  none
      creator:  created by hewitson@bobmac.aei.uni-hannover.de[130.75.117.65] on MACI/7.6 (R2008a)/1.9.1 beta (R2008a)
      description:  
      data: (0,-1.75921525387737) (0.1,-0.323940403980841) (0.2,1.70580759558634) (0.3,0.74566737561773) (0.4,-0.386452719524098) ...
      -------- tsdata 01 ------------
      
      fs:  10
      x:  [1 100], double
      y:  [1 100], double
      xunits:  s
      yunits:  V
      nsecs:  10
      t0:  1970-01-01 00:00:00.000
      -------------------------------
      
      hist:  ao / ao / $Id: objects_working_content.html,v 1.3 2008/08/25 21:10:07 hewitson Exp $-->$Id: objects_working_content.html,v 1.3 2008/08/25 21:10:07 hewitson Exp $
      mfilename:  
      mdlfilename:  
      -----------------------------
  

Then call the psd method:
      >> a.psd(pl)
      M: running ao/psd
      M:   using default Nfft of 100
      M:   reset window to BH92(100)
      M:   using default overlap of 66.1%
      M: running ao/display
      ----------- ao: PSD(a) -----------
      
      name:  PSD(a)
      creator:  created by hewitson@bobmac.aei.uni-hannover.de[130.75.117.65] on MACI/7.6 (R2008a)/1.9.1 beta (R2008a)
      description:  
      data: (0,0.0488141703757124) (0.1,0.109407517445348) (0.2,0.194309804548859) (0.3,0.453109075098881) (0.4,0.650807772380848) ...
      ----------- fsdata 01 -----------
      
      fs:  10
      x:  [1 51], double
      y:  [1 51], double
      xunits:  empty
      yunits:  V^2/Hz
      t0:  1970-01-01 00:00:00.000
      ---------------------------------
      
      hist:  ao / psd / $Id: objects_working_content.html,v 1.3 2008/08/25 21:10:07 hewitson Exp $
      mfilename:  
      mdlfilename:  
      ----------------------------------
  

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.




©LTP Team