0001 function b = subsref(p, index)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 b = [];
0029
0030 switch length(index)
0031
0032
0033
0034
0035
0036 case 1
0037 switch index.type
0038 case '()'
0039 idx = index.subs{1};
0040 b = p(idx);
0041 case '{}'
0042 idx = index.subs{1};
0043 b = p{idx};
0044 case '.'
0045 switch index.subs
0046 case 'key'
0047 b = p.key;
0048 case 'val'
0049 b = p.val;
0050 case 'version'
0051 b = p.version;
0052 otherwise
0053 error('### unknown field for param object.');
0054 end
0055 otherwise
0056 error('### unknown indexing method for param objects.');
0057 end
0058 case 2
0059
0060
0061
0062 if index(1).type == '.'
0063 fieldName = index(1).subs;
0064
0065 if length(p) == 1
0066 eval(sprintf('b = subsref (p.%s, index(2));',fieldName))
0067 else
0068 error(['### output is not defined because the '...
0069 'parameter is a vector or matrix.']);
0070 end
0071
0072
0073 elseif index(1).type == '()'
0074 idx = index(1).subs{1};
0075 switch index(2).subs
0076 case 'key'
0077 b = p(idx).key;
0078 case 'val'
0079 b = p(idx).val;
0080 case 'version'
0081 b = p(idx).version;
0082 otherwise
0083 error('### unknown field for param object.');
0084 end
0085 else
0086 error('### unknown indexing method for parameter objects.');
0087 end
0088
0089 otherwise
0090 error('### unknown indexing method for parameter objects.');
0091 end
0092
0093
0094