Home > classes > @ao > max.m

max

PURPOSE ^

MAX computes the maximum value of the data in the AO.

SYNOPSIS ^

function varargout = max(varargin)

DESCRIPTION ^

 MAX computes the maximum value of the data in the AO.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: MAX computes the maximum value of the data in the AO.

 CALL:        ao_out = max(ao_in);
              ao_out = max(ao_in, pl);

 PARAMETERS:  see help for data2D/applymethod for additional parameters

 M-FILE INFO: Get information about this methods by calling
              >> ao.getInfo('max')

              Get information about a specified set-plist by calling:
              >> ao.getInfo('max', 'None')

 VERSION:     $Id: max.m,v 1.13 2008/09/08 08:31:56 hewitson Exp $

 HISTORY:     12-03-07 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % MAX computes the maximum value of the data in the AO.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: MAX computes the maximum value of the data in the AO.
0005 %
0006 % CALL:        ao_out = max(ao_in);
0007 %              ao_out = max(ao_in, pl);
0008 %
0009 % PARAMETERS:  see help for data2D/applymethod for additional parameters
0010 %
0011 % M-FILE INFO: Get information about this methods by calling
0012 %              >> ao.getInfo('max')
0013 %
0014 %              Get information about a specified set-plist by calling:
0015 %              >> ao.getInfo('max', 'None')
0016 %
0017 % VERSION:     $Id: max.m,v 1.13 2008/09/08 08:31:56 hewitson Exp $
0018 %
0019 % HISTORY:     12-03-07 M Hewitson
0020 %                 Creation
0021 %
0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023 
0024 function varargout = max(varargin)
0025 
0026   % Check if this is a call for parameters
0027   if utils.helper.isinfocall(varargin{:})
0028     varargout{1} = getInfo(varargin{3});
0029     return
0030   end
0031 
0032   % Collect input variable names
0033   in_names = cell(size(varargin));
0034   for ii = 1:nargin,in_names{ii} = inputname(ii);end
0035 
0036   % Collect all AOs
0037   [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
0038   pl              = utils.helper.collect_objects(varargin(:), 'plist', in_names);
0039 
0040   % Get default parameters
0041   pl = combine(pl, getDefaultPlist);
0042 
0043   % Decide on a deep copy or a modify
0044   bs = copy(as, nargout);
0045 
0046   % Apply method to all AOs
0047   for j=1:numel(bs)
0048     % get max value
0049     if isfield(bs(j).data, 'x')
0050       switch find(pl, 'axis')
0051         case 'x'
0052           [mx, idx] = max(bs(j).data.getX);
0053           my = bs(j).data.getY(idx);
0054         case 'y'
0055           [my, idx] = max(bs(j).data.getY);
0056           mx = bs(j).data.getX(idx);
0057       end
0058       bs(j).setXY(mx, my, 'internal');
0059     else
0060       [my, idx] = max(bs(j).data.getY);
0061       bs(j).setY(my, 'internal');
0062     end
0063     % remove fs and nsecs
0064     if ismethod(bs(j).data, 'setFs')
0065       bs(j).setFs(NaN, 'internal');
0066     end
0067     if ismethod(bs(j).data, 'setNsecs')
0068       bs(j).data.setNsecs(NaN, 'internal');
0069     end
0070     % append history
0071     bs(j).addHistory(getInfo('None'), pl, ao_invars(j), bs(j).hist);
0072     % Set new AO name
0073     bs(j).setName(['max(' ao_invars{j} ')'], 'internal');
0074   end
0075 
0076   % Set output
0077   if nargout > 0
0078     varargout{1} = bs;
0079   end
0080 end
0081 
0082 %--------------------------------------------------------------------------
0083 % Get Info Object
0084 %--------------------------------------------------------------------------
0085 function ii = getInfo(varargin)
0086   if nargin == 1 && strcmpi(varargin{1}, 'None')
0087     sets = {};
0088     pl   = [];
0089   else
0090     sets = {'Default'};
0091     pl   = getDefaultPlist;
0092   end
0093   % Build info object
0094   ii = minfo(mfilename, 'ao', '', utils.const.categories.op, '$Id: max.m,v 1.13 2008/09/08 08:31:56 hewitson Exp $', sets, pl);
0095 end
0096 
0097 %--------------------------------------------------------------------------
0098 % Get Default Plist
0099 %--------------------------------------------------------------------------
0100 function pl_default = getDefaultPlist()
0101 
0102   pl_default = plist('axis',  'y');
0103 end
0104 
0105 % END

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003