


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.23 2008/08/08 12:29:16 hewitson Exp $
HISTORY: 14-05-07 M Hewitson
Creation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


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.23 2008/08/08 12:29:16 hewitson 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 % Get x 0064 x = bs(j).data.getX; 0065 % set new samples 0066 bs(j).setXY(x(samples), bs(j).data.y(samples), 'internal'); 0067 % if this is tsdata, we can collapse it again, maybe 0068 if isa(bs(j).data, 'tsdata') 0069 [fs,t0,fitted] = tsdata.fitfs(bs(j).data.x); 0070 if ~fitted 0071 bs(j).data.collapseX(); 0072 end 0073 end 0074 % Set AO name 0075 bs(j).setName(sprintf('select(%s)', ao_invars{j}), 'internal'); 0076 % Add history 0077 bs(j).addHistory(getInfo, plist, ao_invars(j), bs(j).hist); 0078 end 0079 0080 % Set outputs 0081 if nargout > 0 0082 varargout{1} = bs; 0083 end 0084 0085 end 0086 0087 %-------------------------------------------------------------------------- 0088 % Get Info Object 0089 %-------------------------------------------------------------------------- 0090 function ii = getInfo(varargin) 0091 if nargin == 1 && strcmpi(varargin{1}, 'None') 0092 sets = {}; 0093 pl = []; 0094 else 0095 sets = {'Default'}; 0096 pl = getDefaultPlist; 0097 end 0098 % Build info object 0099 ii = minfo(mfilename, 'ao', '', 'Signal Processing', '$Id: select.m,v 1.23 2008/08/08 12:29:16 hewitson Exp $', sets, pl); 0100 end 0101 0102 %-------------------------------------------------------------------------- 0103 % Get Default Plist 0104 %-------------------------------------------------------------------------- 0105 function pl_default = getDefaultPlist() 0106 pl_default = plist('samples', []); 0107 end 0108 0109 % END