Home > classes > @tsdata > subsasgn.m

subsasgn

PURPOSE ^

SUBSASGN define index assignment for for tsdata properties.

SYNOPSIS ^

function A = subsasgn(A, S, B)

DESCRIPTION ^

 SUBSASGN define index assignment for for tsdata properties.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: SUBSASGN define index assignment for tsdata properties.

 EXAMPLES:    All possible assignments are possible.

 VERSION:     $Id: subsasgn.m,v 1.2 2007/08/13 13:19:17 ingo Exp $

 HISTORY:     31-01-07 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003