Mercurial > hg > ltpda
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % COLLECT_VALUES convert numeric values in to AOs. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: COLLECT_VALUES convert numeric values in to AOs. | |
5 % | |
6 % This provides additional functionality to the collect_objects method. | |
7 % This method collects any single valued numerical data from the input | |
8 % arguments (args), and converts them to cdata AOs. | |
9 % | |
10 % Typicall usage in a class method would be: | |
11 % | |
12 % args = utils.helper.collect_values(varargin(:)); | |
13 % [as, ao_invars] = utils.helper.collect_objects(args, 'ao', in_names); | |
14 % | |
15 % | |
16 % VERSION: $Id: collect_values.m,v 1.6 2011/03/24 19:57:51 ingo Exp $ | |
17 % | |
18 % HISTORY: 2008-06-19 M Hewitson | |
19 % Creation | |
20 % | |
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
22 | |
23 function args = collect_values(args) | |
24 | |
25 % We need to check what kind of object to promote numeric values to. | |
26 const = 'ao'; % as default we promote to an AO | |
27 for jj=1:numel(args) | |
28 if isa(args{jj}, 'ltpda_uoh') | |
29 const = class(args{jj}); | |
30 end | |
31 end | |
32 | |
33 for jj=1:numel(args) | |
34 if isnumeric(args{jj}) | |
35 if ~(isvector(args{jj})) | |
36 name = mat2str(args{jj}); | |
37 else | |
38 name = num2str(args{jj}); | |
39 end | |
40 args{jj} = feval(const, args{jj}); | |
41 args{jj}.setName(name); | |
42 end | |
43 end | |
44 | |
45 end |