Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/sum.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 % SUM computes the sum of the data in the AO. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: SUM computes the sum of the data in the AO. | |
5 % | |
6 % CALL: ao_out = sum(ao_in); | |
7 % ao_out = sum(ao_in, pl); | |
8 % | |
9 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'sum')">Parameters Description</a> | |
10 % | |
11 % VERSION: $Id: sum.m,v 1.34 2011/04/19 18:48:11 ingo Exp $ | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 function varargout = sum(varargin) | |
16 | |
17 % Check if the method was called by another method | |
18 callerIsMethod = utils.helper.callerIsMethod; | |
19 | |
20 % Settings | |
21 operatorName = 'sum'; | |
22 dxFcn = []; | |
23 | |
24 if callerIsMethod | |
25 in_names = {}; | |
26 else | |
27 % Collect input variable names | |
28 in_names = cell(size(varargin)); | |
29 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
30 | |
31 % Check if this is a call for the minfo object | |
32 if utils.helper.isinfocall(varargin{:}) | |
33 varargout{1} = getInfo(varargin{3}); | |
34 return | |
35 end | |
36 | |
37 end | |
38 | |
39 % Here we are forced to collect objects so that we can check that each ao | |
40 % is the correct type and shape for doing det. | |
41 [as, dummy, rest] = utils.helper.collect_objects(varargin, 'ao', in_names); | |
42 | |
43 % Check for the correct data objects: Throw an error for data2D objects. | |
44 as.checkDataType('data3D'); | |
45 | |
46 copyObjects = nargout>0; | |
47 | |
48 % Apply method to all AOs | |
49 [out, pl] = ao.applymethod(copyObjects, callerIsMethod, in_names, operatorName, dxFcn, @getInfo, @getDefaultPlist, varargin{:}); | |
50 | |
51 % set outputs | |
52 if isa(out, 'ao') | |
53 out = fixAxisData(out, pl); | |
54 % Clear errors | |
55 out.clearErrors(pl); | |
56 end | |
57 | |
58 % set outputs | |
59 varargout = utils.helper.setoutputs(nargout, out); | |
60 | |
61 end | |
62 | |
63 %-------------------------------------------------------------------------- | |
64 % Get Info Object | |
65 %-------------------------------------------------------------------------- | |
66 function ii = getInfo(varargin) | |
67 ii = minfo.getInfoAxis(mfilename, @getDefaultPlist, varargin); | |
68 end | |
69 | |
70 %-------------------------------------------------------------------------- | |
71 % Get Default Plist | |
72 %-------------------------------------------------------------------------- | |
73 | |
74 function plout = getDefaultPlist(set) | |
75 persistent pl; | |
76 persistent lastset; | |
77 if ~exist('pl', 'var') || isempty(pl) || ~strcmp(lastset, set) | |
78 pl = buildplist(set); | |
79 lastset = set; | |
80 end | |
81 plout = pl; | |
82 end | |
83 | |
84 function plout = buildplist(varargin) | |
85 plout = plist.getDefaultAxisPlist(varargin{:}); | |
86 end | |
87 |