comparison m-toolbox/classes/@ao/min.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 % MIN computes the minimum value of the data in the AO.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: MIN computes the minimum value of the data in the AO.
5 %
6 % CALL: ao_out = min(ao_in);
7 % ao_out = min(ao_in, pl);
8 %
9 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'min')">Parameters Description</a>
10 %
11 % VERSION: $Id: min.m,v 1.31 2011/04/08 08:56:16 hewitson Exp $
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 function varargout = min(varargin)
16
17 % Check if this is a call for parameters
18 if utils.helper.isinfocall(varargin{:})
19 varargout{1} = getInfo(varargin{3});
20 return
21 end
22
23 % Collect input variable names
24 in_names = cell(size(varargin));
25 for ii = 1:nargin,in_names{ii} = inputname(ii);end
26
27 % Collect all AOs
28 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
29 pl = utils.helper.collect_objects(varargin(:), 'plist');
30
31 % Get default parameters
32 pl = parse(pl, getDefaultPlist);
33
34 % Decide on a deep copy or a modify
35 bs = copy(as, nargout);
36
37
38 % Apply method to all AOs
39 for j=1:numel(bs)
40 skip = false;
41 % get min value
42 if isa(bs(j).data, 'data3D')
43 skip = true;
44 warning('!!! Skipping AO [%s]: min doesn''t work for 3D data at the moment', bs(j).name);
45 elseif isa(bs(j).data, 'data2D')
46 switch lower(find(pl, 'axis'))
47 case 'x'
48 [mx, idx] = min(bs(j).data.getX);
49 my = bs(j).data.getY(idx);
50 case 'y'
51 [my, idx] = min(bs(j).data.getY);
52 mx = bs(j).data.getX(idx);
53 otherwise
54 error('### The axis must one of ''x'' or ''y''.');
55 end
56 d = xydata(mx, my);
57 d.xunits = bs(j).data.xunits;
58 d.yunits = bs(j).data.yunits;
59 bs(j).data = d;
60 else
61 my = min(bs(j).data.getY);
62 bs(j).data.setY(my);
63 end
64
65 if ~skip
66 % Set new AO name
67 bs(j).name = ['min(' ao_invars{j} ')'];
68 % append history
69 bs(j).addHistory(getInfo('None'), pl, ao_invars(j), bs(j).hist);
70 % clear errors
71 bs(j).clearErrors(pl);
72 end
73 end
74
75
76 % Set output
77 if nargout == numel(bs)
78 % List of outputs
79 for ii = 1:numel(bs)
80 varargout{ii} = bs(ii);
81 end
82 else
83 % Single output
84 varargout{1} = bs;
85 end
86 end
87
88 %--------------------------------------------------------------------------
89 % Get Info Object
90 %--------------------------------------------------------------------------
91 function ii = getInfo(varargin)
92 if nargin == 1 && strcmpi(varargin{1}, 'None')
93 sets = {};
94 pl = [];
95 else
96 sets = {'Default'};
97 pl = getDefaultPlist;
98 end
99 % Build info object
100 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.op, '$Id: min.m,v 1.31 2011/04/08 08:56:16 hewitson Exp $', sets, pl);
101 end
102
103 %--------------------------------------------------------------------------
104 % Get Default Plist
105 %--------------------------------------------------------------------------
106 function plout = getDefaultPlist()
107 persistent pl;
108 if exist('pl', 'var')==0 || isempty(pl)
109 pl = buildplist();
110 end
111 plout = pl;
112 end
113
114 function pl = buildplist()
115 pl = plist.AXIS_2D_PLIST;
116 end
117
118 % END