SUBSREF Define field name indexing for fsdata objects. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: SUBSREF Define field name indexing for fsdata objects. EXAMPLES: All possible accesses are possible. VERSION: $Id: subsref.m,v 1.12 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 fsdata objects. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: SUBSREF Define field name indexing for fsdata objects. 0007 % 0008 % EXAMPLES: All possible accesses are possible. 0009 % 0010 % VERSION: $Id: subsref.m,v 1.12 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 varargout = subsref(fsd, index) 0019 % % SUBSREF Define field name indexing for fsdata objects. 0020 % % 0021 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0022 % % 0023 % % DESCRIPTION: SUBSREF Define field name indexing for fsdata objects. 0024 % % 0025 % % EXAMPLES: 0026 % % 0027 % % nesting level == 1 0028 % % 0029 % % >> data(2) 0030 % % >> data(2:12) 0031 % % >> [f,xx] = data(2); 0032 % % >> [f,xx] = data(2:12); 0033 % % >> xx = data(2); not possible 0034 % % >> xx = data(2:12); not possible 0035 % % >> data(2,1) not possible 0036 % % >> [f,xx] = data(2,1); not possible 0037 % % >> xx = data.xx; 0038 % % >> f = data.f; 0039 % % >> name = data.name; 0040 % % ... 0041 % % 0042 % % nesting level == 2 0043 % % 0044 % % >> data.f(2) 0045 % % >> data.f(2:12) 0046 % % >> f = data.f(2); 0047 % % >> data.f(2,1) not possible 0048 % % >> f = data.f(2,1); not possible 0049 % % >> data_vector(1).t 0050 % % >> t = data_vector(1).t; 0051 % % >> data_vector(1:3).t; not possible 0052 % % >> t = data_vector(1:3).t; not possible 0053 % % >> data_matrix(1,2).t 0054 % % >> t = data_matrix(1,2).t; 0055 % % 0056 % % VERSION: $Id: subsref.m,v 1.12 2007/08/01 13:55:52 ingo Exp $ 0057 % % 0058 % % HISTORY: 31-01-07 M Hewitson 0059 % % Creation 0060 % % 0061 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0062 % 0063 % switch length(index) 0064 % case 1 % fsd(1:10) or fsd.f or fsd.xx 0065 % switch index.type 0066 % 0067 % % INFO: data(2) 0068 % % data(2:12) 0069 % % [f,xx] = data(2); 0070 % % [f,xx] = data(2:12); 0071 % % xx = data(2); not possible 0072 % % xx = data(2:12); not possible 0073 % case '()' 0074 % if length (index.subs) == 1 0075 % 0076 % idx = index.subs{1}; 0077 % 0078 % % assure that the number of outputs matches 0079 % if nargout == 0 0080 % disp(fsd.f(idx)) 0081 % disp(fsd.xx(idx)) 0082 % elseif nargout == 1 0083 % varargout{1} = [fsd.f(idx) fsd.xx(idx)]; 0084 % elseif nargout == 2 0085 % varargout{1} = fsd.f(idx); 0086 % varargout{2} = fsd.xx(idx); 0087 % else 0088 % error('### the number of outputs does not match. Please use two outputs.') 0089 % end 0090 % 0091 % % INFO: data(2,1) not possible 0092 % % [f,xx] = data(2,1); not possible 0093 % else % length (index.subs) == 2 0094 % error ('### the x- or y-data are a vector. Do not use two indices.'); 0095 % end 0096 % 0097 % % INFO: xx = data.xx; 0098 % % f = data.f; 0099 % % name = data.name; 0100 % % ... 0101 % case '.' 0102 % fieldName = index.subs; 0103 % eval(sprintf('varargout{1} = fsd.%s;', fieldName)); 0104 % 0105 % otherwise 0106 % error('### unknown indexing method for fsdata objects.'); 0107 % end 0108 % % INFO: 0109 % case 2 % fsd.f(1:10) or fsd.xx(1:10) 0110 % 0111 % % INFO: data.f(2) 0112 % % data.f(2:12) 0113 % % f = data.f(2); 0114 % % data.f(2,1) not possible 0115 % % f = data.f(2,1); not possible 0116 % % data_vector(1).f 0117 % % f = data_vector(1).f; 0118 % % data_vector(1:3).f; not possible 0119 % % f = data_vector(1:3).f; not possible 0120 % % data_matrix(1,2).f 0121 % % f = data_matrix(1,2).f; 0122 % 0123 % if index(1).type == '.' 0124 % 0125 % fieldName = index(1).subs; 0126 % 0127 % % e.g. t = data.xx(2,1); 0128 % if length(index(2).subs) > 1 && ~ischar(index(2).subs) 0129 % error('### the x- or y-data are a vector. Do not use two indices.'); 0130 % end 0131 % 0132 % switch fieldName 0133 % case 'f' 0134 % f = fsd.f(index(2).subs{1}); 0135 % varargout{1} = f; 0136 % case 'xx' 0137 % xx = fsd.xx(index(2).subs{1}); 0138 % varargout{1} = xx; 0139 % otherwise 0140 % error('### not possible field. Use ''data.f'' or ''data.xx''.'); 0141 % end 0142 % 0143 % % INFO: data_vector(1).f 0144 % % f = data_vector(1).f; 0145 % % data_vector(1:3).f; not possible 0146 % % f = data_vector(1:3).f; not possible 0147 % 0148 % elseif strcmp (index(1).type, '()') 0149 % 0150 % if length(index(1).subs) == 1 0151 % % INFO: f = data_vector(1).f; 0152 % if length(index(1).subs{1}) == 1 0153 % varargout{1} = subsref (fsd(index(1).subs{1}), index(2)); 0154 % % INFO: f = data_vector(1:3).f; 0155 % else 0156 % error(['### output for the indexing ' ... 0157 % sprintf('(%d:%d) is not defined', min(index(1).subs{1}), ... 0158 % max(index(1).subs{1}))]); 0159 % end 0160 % % INFO: data_matrix(1,2).f 0161 % % f = data_matrix(1,2).f; 0162 % elseif length(index(1).subs) == 2 0163 % varargout{1} = subsref (fsd(index(1).subs{1},index(1).subs{2}), index(2)); 0164 % end 0165 % 0166 % else 0167 % error('### unknown indexing method for fsdata objects.'); 0168 % end 0169 % otherwise 0170 % error('### unknown indexing method for fsdata objects.'); 0171 % end 0172 % 0173 % % END 0174 %