comparison m-toolbox/classes/@ao/mode.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 % MODE computes the modal value of the data in the AO.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: MODE computes the modal value of the data in the AO.
5 %
6 % CALL: ao_out = mode(ao_in);
7 % ao_out = mode(ao_in, pl);
8 %
9 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'mode')">Parameters Description</a>
10 %
11 % VERSION: $Id: mode.m,v 1.29 2011/04/19 18:48:11 ingo Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = mode(varargin)
16
17 % Check if the method was called by another method
18 callerIsMethod = utils.helper.callerIsMethod;
19
20 % Settings
21 operatorName = 'mode';
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 end
31
32 % Here we are forced to collect objects so that we can check that each ao
33 % is the correct type for doing diag.
34 as = utils.helper.collect_objects(varargin(:), 'ao', in_names);
35
36 % We filter out the data3D objects here since we don't know what to do
37 % with them so far.
38 aos = [];
39 for kk=1:numel(as)
40 if isa(as(kk).data, 'data3D')
41 warning('!!! Skipping ao [%s] - %s can''t operate on data3D objects at the moment.', as(kk).name, operatorName);
42 else
43 aos = [aos as(kk)];
44 end
45 end
46 if isempty(as) % try for getInfo
47 out = ao.applymethod(0, callerIsMethod, in_names, operatorName, dxFcn, @getInfo, @getDefaultPlist, varargin{:});
48 varargout{1} = out;
49 return
50 end
51
52 copyObjects = nargout>0;
53 [bs, pl] = ao.applymethod(copyObjects, callerIsMethod, in_names, operatorName, dxFcn, @getInfo, @getDefaultPlist, varargin{:});
54
55 if isa(bs, 'ao')
56 bs = fixAxisData(bs, pl);
57 % Clear errors
58 bs.clearErrors(pl);
59 end
60
61 % set outputs
62 varargout = utils.helper.setoutputs(nargout, bs);
63 end
64
65 %--------------------------------------------------------------------------
66 % Get Info Object
67 %--------------------------------------------------------------------------
68 function ii = getInfo(varargin)
69 ii = minfo.getInfoAxis(mfilename, @getDefaultPlist, varargin);
70 end
71
72 %--------------------------------------------------------------------------
73 % Get Default Plist
74 %--------------------------------------------------------------------------
75
76 function plout = getDefaultPlist(set)
77 persistent pl;
78 persistent lastset;
79 if ~exist('pl', 'var') || isempty(pl) || ~strcmp(lastset, set)
80 pl = buildplist(set);
81 lastset = set;
82 end
83 plout = pl;
84 end
85
86 function plout = buildplist(varargin)
87 plout = plist.getDefaultAxisPlist(varargin{:});
88 end