comparison m-toolbox/classes/@ao/yunits.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 % YUNITS Get the data property 'yunits'.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: Get the data property 'yunits'.
5 %
6 % CALL: val = yunits(a1,a2,a3,...)
7 % val = yunits(as)
8 % val = as.yunits()
9 %
10 % INPUTS: aN - input analysis objects
11 % as - input analysis objects array
12 %
13 % OUTPUTS: val - array of with 'yunits', one for each input
14 %
15 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'yunits')">Parameters Description</a>
16 %
17 % VERSION: $Id: yunits.m,v 1.12 2011/04/08 08:56:12 hewitson Exp $
18 %
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20
21 function varargout = yunits(varargin)
22
23 %%% Check if this is a call for parameters
24 if utils.helper.isinfocall(varargin{:})
25 varargout{1} = getInfo(varargin{3});
26 return
27 end
28
29 import utils.const.*
30 property = 'yunits';
31
32 % Check if the method was called by another method
33 callerIsMethod = utils.helper.callerIsMethod;
34
35 if ~callerIsMethod
36 % Collect all AOs
37 as = utils.helper.collect_objects(varargin(:), 'ao');
38 else
39 % Assume the input is a single AO or a vector of AOs
40 as = varargin{1};
41 end
42
43 % Extract the property
44 for jj = 1:numel(as)
45 if isprop(as(jj).data, property)
46 out(jj) = as(jj).data.(property);
47 else
48 utils.helper.msg(msg.IMPORTANT, 'The %dth object has no %s property. Setting result to empty unit', jj, property);
49 out(jj) = unit();
50 end
51 end
52
53 % Set output
54 if nargout == numel(as)
55 % List of outputs
56 for ii = 1:numel(as)
57 varargout{ii} = out(ii);
58 end
59 else
60 % Single output
61 varargout{1} = out;
62 end
63
64 end
65
66 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 % Local Functions %
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69
70 %--------------------------------------------------------------------------
71 % Get Info Object
72 %--------------------------------------------------------------------------
73 function ii = getInfo(varargin)
74 if nargin == 1 && strcmpi(varargin{1}, 'None')
75 sets = {};
76 pl = [];
77 else
78 sets = {'Default'};
79 pl = getDefaultPlist();
80 end
81 % Build info object
82 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.helper, '$Id: yunits.m,v 1.12 2011/04/08 08:56:12 hewitson Exp $', sets, pl);
83 ii.setModifier(false);
84 end
85
86 %--------------------------------------------------------------------------
87 % Get Default Plist
88 %--------------------------------------------------------------------------
89 function plout = getDefaultPlist()
90 persistent pl;
91 if ~exist('pl', 'var') || isempty(pl)
92 pl = buildplist();
93 end
94 plout = pl;
95 end
96
97 function pl = buildplist()
98 pl = plist.EMPTY_PLIST;
99 end
100