Home > classes > @plist > subsref.m

subsref

PURPOSE ^

SUBSREF Define field name indexing for plist objects.

SYNOPSIS ^

function b = subsref(a, index)

DESCRIPTION ^

 SUBSREF Define field name indexing for plist objects.
 
 M Hewitson 30-01-07
 
 $Id: subsref.html,v 1.1 2007/06/08 14:15:06 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function b = subsref(a, index)
0002 
0003 % SUBSREF Define field name indexing for plist objects.
0004 %
0005 % M Hewitson 30-01-07
0006 %
0007 % $Id: subsref.html,v 1.1 2007/06/08 14:15:06 hewitson Exp $
0008 %
0009 
0010 b = [];
0011 
0012 % index
0013 switch length(index)
0014   case 1
0015     
0016     switch index.type
0017       case '()'
0018         idx = index.subs{1};
0019 %         b = a.params(idx);
0020         b = a(idx);        
0021       case '.'
0022         
0023 %         index
0024         switch index.subs
0025           case 'params'
0026             b = a.params(:);
0027           otherwise
0028             error('### unknown property field for plist object.')
0029         end
0030       otherwise
0031         error('### unknown indexing method for plist object.')
0032     end
0033     
0034   case 2
0035     
0036     for i=1:length(index)
0037       switch index(i).type
0038         case '.'
0039           fieldName = index(i).subs;
0040         case '()'
0041           switch fieldName
0042             case 'params'
0043               for idx = index(i).subs{1}
0044                 b = [b a.params(idx)];
0045               end
0046             otherwise
0047               error(sprintf('### can not index field %s', fieldName));
0048           end
0049       end
0050     end
0051     
0052     
0053   otherwise
0054     error('### unknown indexing method for plist object');
0055 end
0056 
0057 % END
0058

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003