SUBSREF Define field name indexing for parameter list objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: SUBSREF Define field name indexing for parameter list objects. EXAMPLES: All possible accesses are possible. VERSION: $Id: subsref.m,v 1.10 2007/08/01 13:55:52 ingo Exp $ HISTORY: 31-01-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function B = subsref(A, S) 0002 % SUBSREF Define field name indexing for parameter list objects. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: SUBSREF Define field name indexing for parameter list objects. 0007 % 0008 % EXAMPLES: All possible accesses are possible. 0009 % 0010 % VERSION: $Id: subsref.m,v 1.10 2007/08/01 13:55:52 ingo Exp $ 0011 % 0012 % HISTORY: 31-01-07 M Hewitson 0013 % Creation 0014 % 0015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0016 B = builtin('subsref', A, S); 0017 0018 % function b = subsref(a, index) 0019 % % SUBSREF Define field name indexing for plist objects. 0020 % % 0021 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0022 % % 0023 % % DESCRIPTION: SUBSREF Define field name indexing for tsdata objects. 0024 % % 0025 % % EXAMPLES: 0026 % % 0027 % % nesting level == 1 0028 % % 0029 % % >> pl1 = pl_vector(2); 0030 % % >> pl_vector(2); 0031 % % >> pl1 = pl_matrix(2,1); not possible 0032 % % >> params = pl.params; 0033 % % >> version = pl.version; 0034 % % 0035 % % nesting level == 2 0036 % % 0037 % % >> pl.params(2) 0038 % % >> pl.params(2:12) 0039 % % >> pl = pl.params(2); 0040 % % >> pl.params(2,1) not possible 0041 % % >> pl = pl.params(2,1); not possible 0042 % % >> pl_vector(1).params 0043 % % >> pl = pl_vector(1).params; 0044 % % >> pl_vector(1:3).params; not possible 0045 % % >> pl = pl_vector(1:3).params; not possible 0046 % % >> pl_matrix(1,2).params 0047 % % >> pl = pl_matrix(1,2).params; 0048 % % 0049 % % VERSION: $Id: subsref.m,v 1.10 2007/08/01 13:55:52 ingo Exp $ 0050 % % 0051 % % HISTORY: 31-01-07 M Hewitson 0052 % % Creation 0053 % % 0054 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0055 % 0056 % b = []; 0057 % 0058 % % index 0059 % switch length(index) 0060 % case 1 0061 % 0062 % % INFO: pl1 = pl_vector(2); 0063 % switch index.type 0064 % case '()' 0065 % if length (index.subs) == 1 0066 % idx = index.subs{1}; 0067 % b = a(idx); 0068 % else % length (index.subs) == 2 0069 % error ('### Do not use a plist matrix.'); 0070 % end 0071 % 0072 % % INFO: params = pl.params; 0073 % % version = pl.version; 0074 % case '.' 0075 % 0076 % fieldName = index.subs; 0077 % 0078 % % Not possible field throw error 0079 % if all(strcmp(fieldnames(a),fieldName)==0) 0080 % error([sprintf('### %s is a non-existent field ',fieldName) ... 0081 % 'of a parameter list object.']); 0082 % end 0083 % 0084 % eval(sprintf('b = a.%s;', fieldName)); 0085 % 0086 % otherwise 0087 % error('### unknown indexing method for plist object.') 0088 % end 0089 % 0090 % case 2 0091 % % INFO: pl.params(2) 0092 % % pl.params(2:12) 0093 % % pl = pl.params(2); 0094 % % pl.params(2,1) not possible 0095 % % pl = pl.params(2,1); not possible 0096 % % pl_vector(1).params 0097 % % pl = pl_vector(1).params; 0098 % % pl_vector(1:3).params; not possible 0099 % % pl = pl_vector(1:3).params; not possible 0100 % % pl_matrix(1,2).params 0101 % % pl = pl_matrix(1,2).params; 0102 % 0103 % if index(1).type == '.' 0104 % 0105 % fieldName = index(1).subs; 0106 % 0107 % if length(a) == 1 0108 % eval(sprintf('b = subsref (a.%s, index(2));',fieldName)) 0109 % else 0110 % error(['### output is not defined because the '... 0111 % 'parameter list is vector or matrix.']); 0112 % end 0113 % 0114 % % INFO: pl_vector(1).params 0115 % % pl = pl_vector(1).params; 0116 % % pl_vector(1:3).params; not possible 0117 % % pl = pl_vector(1:3).params; not possible 0118 % 0119 % elseif strcmp (index(1).type, '()') 0120 % 0121 % if length(index(1).subs) == 1 0122 % % INFO: pl = pl_vector(1).params; 0123 % if length(index(1).subs{1}) == 1 0124 % b = subsref (a(index(1).subs{1}), index(2)); 0125 % % INFO: pl = pl_vector(1:3).params; 0126 % else 0127 % error('### output for the indexing (%d:%d) is not defined', ... 0128 % min(index(1).subs{1}), ... 0129 % max(index(1).subs{1})); 0130 % end 0131 % % INFO: pl_matrix(1,2).params 0132 % % pl = pl_matrix(1,2).params; 0133 % elseif length(index(1).subs) == 2 0134 % b = subsref (a(index(1).subs{1},index(1).subs{2}), index(2)); 0135 % end 0136 % 0137 % else 0138 % error('### unknown indexing method for plist objects.'); 0139 % end 0140 % 0141 % otherwise % switch length(index) 0142 % error('### unknown indexing method for plist object'); 0143 % end 0144 % 0145 % % END 0146 %