Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/len.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % LEN overloads the length operator for Analysis objects. Length of the data samples. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: LEN overloads the length operator for Analysis objects. | |
5 % Number of data samples in the analysis objects. | |
6 % LEN(ao) is the length of the elements of ao_in.data. | |
7 % | |
8 % CALL: l = len(ao_in); | |
9 % | |
10 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'len')">Parameters Description</a> | |
11 % | |
12 % VERSION: $Id: len.m,v 1.29 2011/05/17 15:06:10 mauro Exp $ | |
13 % | |
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
15 | |
16 function varargout = len(varargin) | |
17 | |
18 % Check if this is a call for parameters | |
19 if utils.helper.isinfocall(varargin{:}) | |
20 varargout{1} = getInfo(varargin{3}); | |
21 return | |
22 end | |
23 | |
24 % Check if the method was called by another method | |
25 callerIsMethod = utils.helper.callerIsMethod; | |
26 | |
27 if ~callerIsMethod | |
28 % Collect input variable names | |
29 in_names = cell(size(varargin)); | |
30 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
31 | |
32 % Collect all AOs and plists | |
33 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
34 else | |
35 % Assume the input is a single AO or a vector of AOs | |
36 as = varargin{1}; | |
37 end | |
38 | |
39 % go through analysis objects | |
40 out = zeros(size(as)); | |
41 for jj = 1:numel(as) | |
42 out(jj) = numel(as(jj).data.getY); | |
43 end | |
44 | |
45 % Set output | |
46 varargout = utils.helper.setoutputs(nargout, out); | |
47 | |
48 end | |
49 | |
50 %-------------------------------------------------------------------------- | |
51 % Get Info Object | |
52 %-------------------------------------------------------------------------- | |
53 function ii = getInfo(varargin) | |
54 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
55 sets = {}; | |
56 pl = []; | |
57 else | |
58 sets = {'Default'}; | |
59 pl = getDefaultPlist; | |
60 end | |
61 % Build info object | |
62 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.helper, '$Id: len.m,v 1.29 2011/05/17 15:06:10 mauro Exp $', sets, pl); | |
63 ii.setModifier(false); | |
64 end | |
65 | |
66 %-------------------------------------------------------------------------- | |
67 % Get Default Plist | |
68 %-------------------------------------------------------------------------- | |
69 function plout = getDefaultPlist() | |
70 persistent pl; | |
71 if ~exist('pl', 'var') || isempty(pl) | |
72 pl = buildplist(); | |
73 end | |
74 plout = pl; | |
75 end | |
76 | |
77 function pl = buildplist() | |
78 pl = plist.EMPTY_PLIST; | |
79 end |