Mercurial > hg > ltpda
diff m-toolbox/classes/+utils/@helper/collect_values.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/+utils/@helper/collect_values.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,45 @@ +% COLLECT_VALUES convert numeric values in to AOs. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: COLLECT_VALUES convert numeric values in to AOs. +% +% This provides additional functionality to the collect_objects method. +% This method collects any single valued numerical data from the input +% arguments (args), and converts them to cdata AOs. +% +% Typicall usage in a class method would be: +% +% args = utils.helper.collect_values(varargin(:)); +% [as, ao_invars] = utils.helper.collect_objects(args, 'ao', in_names); +% +% +% VERSION: $Id: collect_values.m,v 1.6 2011/03/24 19:57:51 ingo Exp $ +% +% HISTORY: 2008-06-19 M Hewitson +% Creation +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function args = collect_values(args) + + % We need to check what kind of object to promote numeric values to. + const = 'ao'; % as default we promote to an AO + for jj=1:numel(args) + if isa(args{jj}, 'ltpda_uoh') + const = class(args{jj}); + end + end + + for jj=1:numel(args) + if isnumeric(args{jj}) + if ~(isvector(args{jj})) + name = mat2str(args{jj}); + else + name = num2str(args{jj}); + end + args{jj} = feval(const, args{jj}); + args{jj}.setName(name); + end + end + +end