TIMESHIFT for AO/tsdata objects, shifts the time axis such that x(1) = 0. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: TIMESHIFT for AO/tsdata objects, shifts the time axis such that x(1) = 0. The value of t0 is set appropriately. CALL: b = timeshift(a) VERSION: $Id: timeshift.m,v 1.1 2008/02/24 19:52:00 hewitson Exp $ The following call returns a parameter list object that contains the default parameter values: >> pl = timeshift(ao, 'Params') The following call returns a string that contains the routine CVS version: >> version = timeshift(ao,'Version') The following call returns a string that contains the routine category: >> category = timeshift(ao,'Category') HISTORY: 23-02-08 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 function varargout = timeshift(varargin) 0002 % TIMESHIFT for AO/tsdata objects, shifts the time axis such that x(1) = 0. 0003 % 0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0005 % 0006 % DESCRIPTION: TIMESHIFT for AO/tsdata objects, shifts the time axis such 0007 % that x(1) = 0. The value of t0 is set appropriately. 0008 % 0009 % CALL: b = timeshift(a) 0010 % 0011 % VERSION: $Id: timeshift.m,v 1.1 2008/02/24 19:52:00 hewitson Exp $ 0012 % 0013 % The following call returns a parameter list object that contains the 0014 % default parameter values: 0015 % 0016 % >> pl = timeshift(ao, 'Params') 0017 % 0018 % The following call returns a string that contains the routine CVS version: 0019 % 0020 % >> version = timeshift(ao,'Version') 0021 % 0022 % The following call returns a string that contains the routine category: 0023 % 0024 % >> category = timeshift(ao,'Category') 0025 % 0026 % HISTORY: 23-02-08 M Hewitson 0027 % Creation 0028 % 0029 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0030 0031 ALGONAME = mfilename; 0032 VERSION = '$Id: timeshift.m,v 1.1 2008/02/24 19:52:00 hewitson Exp $'; 0033 CATEGORY = 'Helper'; 0034 bs = []; 0035 0036 % Check if this is a call for parameters 0037 if nargin == 2 0038 if isa(varargin{1}, 'ao') && ischar(varargin{2}) 0039 in = char(varargin{2}); 0040 if strcmp(in, 'Params') 0041 varargout{1} = getDefaultPL(); 0042 return 0043 elseif strcmp(in, 'Version') 0044 varargout{1} = VERSION; 0045 return 0046 elseif strcmp(in, 'Category') 0047 varargout{1} = CATEGORY; 0048 return 0049 end 0050 end 0051 end 0052 0053 % Collect input ao's, plist's and ao variable names 0054 in_names = {}; 0055 for ii = 1:nargin 0056 in_names{end+1} = inputname(ii); 0057 end 0058 0059 [as, ps, invars] = collect_inputs(varargin, in_names); 0060 0061 0062 % Check input analysis object 0063 for j=1:numel(as) 0064 a = as(j); 0065 d = get(a, 'data'); 0066 dinfo = whos('d'); 0067 0068 % Which data type do we have 0069 dtype = dinfo.class; 0070 switch dtype 0071 case 'tsdata' 0072 0073 x0 = a.data.x(1); 0074 t0 = a.data.t0 - x0; 0075 x = a.data.x - x0; 0076 a.data.x = x; 0077 a.data.t0 = t0; 0078 0079 case {'fsdata', 'cdata', 'xydata'} 0080 error('### I don''t work for frequency-series, xy and constant data.'); 0081 otherwise 0082 error('### unknown data type. They can not be addded.') 0083 end 0084 0085 % add to output 0086 bs = [bs a]; 0087 end 0088 0089 % Reshape the ouput to the same size of the input 0090 bs = reshape(bs, size(as)); 0091 0092 varargout{1} = bs; 0093 0094 0095 %-------------------------------------------------------------------------- 0096 % Get default params 0097 function plo = getDefaultPL() 0098 0099 plo = plist(); 0100 0101 % END