Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/median.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 % MEDIAN computes the median value of the data in the AO. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: MEDIAN computes the median value of the data in the AO. | |
5 % | |
6 % CALL: ao_out = median(ao_in); | |
7 % ao_out = median(ao_in, pl); | |
8 % | |
9 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'median')">Parameters Description</a> | |
10 % | |
11 % VERSION: $Id: median.m,v 1.38 2011/04/19 18:48:11 ingo Exp $ | |
12 % | |
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
14 | |
15 function varargout = median(varargin) | |
16 | |
17 % Check if the method was called by another method | |
18 callerIsMethod = utils.helper.callerIsMethod; | |
19 | |
20 % Settings | |
21 operatorName = 'median'; | |
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(aos) % 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 | |
53 copyObjects = nargout>0; | |
54 [bs, pl] = ao.applymethod(copyObjects, callerIsMethod, in_names, operatorName, dxFcn, @getInfo, @getDefaultPlist, varargin{:}); | |
55 | |
56 if isa(bs, 'ao') | |
57 bs = fixAxisData(bs, pl); | |
58 % Clear errors | |
59 bs.clearErrors(pl); | |
60 end | |
61 | |
62 % set outputs | |
63 varargout = utils.helper.setoutputs(nargout, bs); | |
64 | |
65 end | |
66 | |
67 %-------------------------------------------------------------------------- | |
68 % Get Info Object | |
69 %-------------------------------------------------------------------------- | |
70 function ii = getInfo(varargin) | |
71 | |
72 ii = minfo.getInfoAxis(mfilename, @getDefaultPlist, varargin); | |
73 end | |
74 | |
75 %-------------------------------------------------------------------------- | |
76 % Get Default Plist | |
77 %-------------------------------------------------------------------------- | |
78 | |
79 function plout = getDefaultPlist(set) | |
80 persistent pl; | |
81 persistent lastset; | |
82 if ~exist('pl', 'var') || isempty(pl) || ~strcmp(lastset, set) | |
83 pl = buildplist(set); | |
84 lastset = set; | |
85 end | |
86 plout = pl; | |
87 end | |
88 | |
89 function plout = buildplist(varargin) | |
90 plout = plist.getDefaultAxisPlist(varargin{:}); | |
91 end | |
92 |