SUBSASGN define index assignment for xydata properties. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: SUBSASGN define index assignment for xydata properties. EXAMPLES: All possible assignment are possible. VERSION: $Id: subsasgn.m,v 1.2 2007/08/13 13:19:17 ingo Exp $ HISTORY: 31-01-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function A = subsasgn(A, S, B) 0002 % SUBSASGN define index assignment for xydata properties. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: SUBSASGN define index assignment for xydata properties. 0007 % 0008 % EXAMPLES: All possible assignment are possible. 0009 % 0010 % VERSION: $Id: subsasgn.m,v 1.2 2007/08/13 13:19:17 ingo Exp $ 0011 % 0012 % HISTORY: 31-01-07 M Hewitson 0013 % Creation 0014 % 0015 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0016 A = builtin ('subsasgn', A, S, B); 0017 0018 0019 % function xy = subsasgn(xy, index, val) 0020 % 0021 % % SUBSASGN define index assignment for vectors in xydata. 0022 % % 0023 % % M Hewitson 30-01-07 0024 % % 0025 % % $Id: subsasgn.m,v 1.2 2007/08/13 13:19:17 ingo Exp $ 0026 % % 0027 % 0028 % if size(val,2) > size(val,1) 0029 % val = val.'; 0030 % end 0031 % 0032 % switch length(index) 0033 % case 1 % ts(idx) = [] or ts.t = [] or ts.x = [] 0034 % switch index.type 0035 % case '()' 0036 % idx = index.subs{1}; 0037 % if length(val) ~= length(idx) 0038 % error('### number of values does not match number of indices.'); 0039 % end 0040 % xy.x(idx) = val(1,:); 0041 % xy.y(idx) = val(2,:); 0042 % case '.' 0043 % switch index.subs 0044 % case 'x' 0045 % xy.x = val; 0046 % if length(val) ~= length(xy.y) 0047 % warning('!!! X vector not consistent with Y vector'); 0048 % end 0049 % case 'y' 0050 % xy.y = val; 0051 % if length(val) ~= length(ts.x) 0052 % warning('!!! Y vector no consistent with X vector'); 0053 % end 0054 % otherwise 0055 % error('### unknown field for indexing.'); 0056 % end 0057 % otherwise 0058 % error('### unknown indexing method for xydata objects.'); 0059 % end 0060 % case 2 % ts.t(idx) = [] or ts.x(idx) = [] 0061 % 0062 % if index(1).type == '.' 0063 % % first index gets us field name 0064 % fieldName = index(1).subs; 0065 % % second index gets us indices 0066 % idx = index(2).subs{1}; 0067 % switch fieldName 0068 % case 'x' 0069 % xy.x(idx) = val; 0070 % case 'y' 0071 % xy.y(idx) = val; 0072 % otherwise 0073 % error('### unknown field to index 1.'); 0074 % end 0075 % else 0076 % error('### unknown indexing method for xydata objects.'); 0077 % end 0078 % 0079 % otherwise 0080 % error('### unknown indexing method for xydata objects.'); 0081 % end 0082 % 0083 % END