Home > classes > @ao > select.m

select

PURPOSE ^

SELECT select particular samples from the input AOs and return new AOs with only those samples.

SYNOPSIS ^

function varargout = select(varargin)

DESCRIPTION ^

 SELECT select particular samples from the input AOs and return new AOs with only those samples.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: SELECT select particular samples from the input AOs and return
              new AOs with only those samples.

 CALL:        b = select(a, [1 2 3 4]);
              b = select(a, pl)

 PARAMETERS: 'samples'  - a list of samples to select

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

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

 VERSION:     $Id: select.m,v 1.26 2008/09/05 11:05:29 ingo Exp $

 HISTORY:     14-05-07 M Hewitson
                 Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % SELECT select particular samples from the input AOs and return new AOs with only those samples.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: SELECT select particular samples from the input AOs and return
0005 %              new AOs with only those samples.
0006 %
0007 % CALL:        b = select(a, [1 2 3 4]);
0008 %              b = select(a, pl)
0009 %
0010 % PARAMETERS: 'samples'  - a list of samples to select
0011 %
0012 % M-FILE INFO: Get information about this methods by calling
0013 %              >> ao.getInfo('select')
0014 %
0015 %              Get information about a specified set-plist by calling:
0016 %              >> ao.getInfo('select', 'None')
0017 %
0018 % VERSION:     $Id: select.m,v 1.26 2008/09/05 11:05:29 ingo Exp $
0019 %
0020 % HISTORY:     14-05-07 M Hewitson
0021 %                 Creation
0022 %
0023 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0024 
0025 function varargout = select(varargin)
0026 
0027   % Check if this is a call for parameters
0028   if utils.helper.isinfocall(varargin{:})
0029     varargout{1} = getInfo(varargin{3});
0030     return
0031   end
0032 
0033   import utils.const.*
0034   utils.helper.msg(msg.MNAME, 'running %s/%s', mfilename('class'), mfilename);
0035   
0036   % Collect input variable names
0037   in_names = cell(size(varargin));
0038   for ii = 1:nargin,in_names{ii} = inputname(ii);end
0039 
0040   % Collect all AOs and plists
0041   [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
0042   [pl, pl_invars, rest] = utils.helper.collect_objects(varargin(:), 'plist', in_names);
0043 
0044   % Decide on a deep copy or a modify
0045   bs = copy(as, nargout);
0046 
0047   % Combine plists
0048   pl = combine(pl, getDefaultPlist);
0049 
0050   % Check for samples in arguments
0051   samples  = [];
0052   for j=1:numel(rest)
0053     if isnumeric(rest{j})
0054       samples = [samples rest{j}];
0055     end
0056   end
0057 
0058   % Get sample selection from plist
0059   samples = [samples find(pl, 'samples')];
0060 
0061   % Loop over input AOs
0062   for j=1:numel(bs)
0063     if isa(bs(j).data, 'cdata')
0064       bs(j).setY(bs(j).data.y(samples), 'internal');
0065     else
0066     % Get x
0067     x = bs(j).data.getX;
0068     % set new samples
0069     bs(j).setXY(x(samples), bs(j).data.y(samples), 'internal');
0070     % if this is tsdata, we can collapse it again, maybe
0071     if isa(bs(j).data, 'tsdata')
0072       [fs,t0,fitted] = tsdata.fitfs(bs(j).data.x);
0073       if ~fitted
0074         bs(j).data.collapseX();
0075       end
0076     end
0077     end
0078     % Set AO name
0079     bs(j).setName(sprintf('select(%s)', ao_invars{j}), 'internal');
0080     % Add history
0081     bs(j).addHistory(getInfo, pl, ao_invars(j), bs(j).hist);
0082   end
0083 
0084   % Set outputs
0085   if nargout > 0
0086     varargout{1} = bs;
0087   end
0088 
0089 end
0090 
0091 %--------------------------------------------------------------------------
0092 % Get Info Object
0093 %--------------------------------------------------------------------------
0094 function ii = getInfo(varargin)
0095   if nargin == 1 && strcmpi(varargin{1}, 'None')
0096     sets = {};
0097     pl   = [];
0098   else
0099     sets = {'Default'};
0100     pl   = getDefaultPlist;
0101   end
0102   % Build info object
0103   ii = minfo(mfilename, 'ao', '', utils.const.categories.sigproc, '$Id: select.m,v 1.26 2008/09/05 11:05:29 ingo Exp $', sets, pl);
0104 end
0105 
0106 %--------------------------------------------------------------------------
0107 % Get Default Plist
0108 %--------------------------------------------------------------------------
0109 function pl_default = getDefaultPlist()
0110   pl_default = plist('samples', []);
0111 end
0112 
0113 % END

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