0001 function b = subsref(vals, index)
0002
0003
0004
0005
0006
0007
0008
0009
0010 b = [];
0011
0012 switch length(index)
0013 case 1
0014 switch index.type
0015
0016 case '()'
0017 if length(index.subs) == 1
0018 idx = index.subs{1};
0019 [m,n] = size(vals.vals);
0020
0021 if (m*n >= index.subs{1})
0022 if (m ~= 1) && (n~=1)
0023 warning ('### you grab to a matrix with a single index', inputname(1));
0024 end
0025 b = [vals.vals(idx)];
0026 else
0027 error('### the index exceeds the vector dimension');
0028 end
0029
0030 else
0031 [m,n] = size(vals.vals);
0032 if (m >= index.subs{1})
0033 if (n >= index.subs{2})
0034 b = vals.vals(index.subs{1}, index.subs{2});
0035 else
0036 error('### the N index exceeds the MxN matrix dimension.');
0037 end
0038 else
0039 error('### the M index exceeds the MxN matrix dimension.');
0040 end
0041 end
0042
0043 case '.'
0044 fieldName = index.subs;
0045 eval(sprintf('b = vals.%s;', fieldName));
0046
0047 otherwise
0048 error('### unknown indexing method for tsdata objects.');
0049 end
0050 case 2
0051
0052 if index(1).type == '.'
0053
0054
0055 fieldName = index(1).subs;
0056
0057
0058 idx = index(2).subs{1};
0059 switch fieldName
0060 case 'vals'
0061 b = subsref(vals, index(2));
0062 otherwise
0063 error('### unknown field to index 1.');
0064 end
0065
0066 else
0067 error('### unknown indexing method for cdata objects.');
0068 end
0069 otherwise
0070 error('### unknown indexing method for cdata objects.');
0071 end
0072
0073
0074