LEN overloads the length operator for Analysis objects. Length of the data samples. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: LEN overloads the length operator for Analysis objects. Number of data samples in the analysis object. LEN(ao) is the length of the elements of ao.data. CALL: l = len(ao_in); M-FILE INFO: Get information about this methods by calling >> ao.getInfo('len') Get information about a specified set-plist by calling: >> ao.getInfo('len', 'None') VERSION: $Id: len.m,v 1.19 2008/09/05 11:05:29 ingo Exp $ HISTORY: 24-04-07 M Hewitson Creation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % LEN overloads the length operator for Analysis objects. Length of the data samples. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: LEN overloads the length operator for Analysis objects. 0005 % Number of data samples in the analysis object. 0006 % LEN(ao) is the length of the elements of ao.data. 0007 % 0008 % CALL: l = len(ao_in); 0009 % 0010 % M-FILE INFO: Get information about this methods by calling 0011 % >> ao.getInfo('len') 0012 % 0013 % Get information about a specified set-plist by calling: 0014 % >> ao.getInfo('len', 'None') 0015 % 0016 % VERSION: $Id: len.m,v 1.19 2008/09/05 11:05:29 ingo Exp $ 0017 % 0018 % HISTORY: 24-04-07 M Hewitson 0019 % Creation 0020 % 0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0022 0023 function varargout = len(varargin) 0024 0025 % Check if this is a call for parameters 0026 if utils.helper.isinfocall(varargin{:}) 0027 varargout{1} = getInfo(varargin{3}); 0028 return 0029 end 0030 0031 if nargout == 0 0032 error('### len cannot be used as a modifier. Please give an output variable.'); 0033 end 0034 0035 import utils.const.* 0036 utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename); 0037 0038 % Collect input variable names 0039 in_names = cell(size(varargin)); 0040 for ii = 1:nargin,in_names{ii} = inputname(ii);end 0041 0042 % Collect all AOs and plists 0043 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); 0044 0045 % go through analysis objects 0046 data_len = zeros(size(as)); 0047 for j=1:numel(as) 0048 data_len(j) = length(as(j).data.getY); 0049 end 0050 0051 % Set outputs 0052 varargout{1} = data_len; 0053 end 0054 0055 %-------------------------------------------------------------------------- 0056 % Get Info Object 0057 %-------------------------------------------------------------------------- 0058 function ii = getInfo(varargin) 0059 if nargin == 1 && strcmpi(varargin{1}, 'None') 0060 sets = {}; 0061 pl = []; 0062 else 0063 sets = {'Default'}; 0064 pl = getDefaultPlist; 0065 end 0066 % Build info object 0067 ii = minfo(mfilename, 'ao', '', utils.const.categories.helper, '$Id: len.m,v 1.19 2008/09/05 11:05:29 ingo Exp $', sets, pl); 0068 end 0069 0070 %-------------------------------------------------------------------------- 0071 % Get Default Plist 0072 %-------------------------------------------------------------------------- 0073 function pl_default = getDefaultPlist() 0074 pl_default = plist(); 0075 end 0076 0077 % END