comparison m-toolbox/classes/@ltpda_uo/processSetterValues.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 % PROCESSSETTERVALUES
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: PROCESSSETTERVALUES.
5 % 1. Checks if the value is in the plist
6 % 2. Checks if there are more than one value that the number
7 % of values are the same as the number of objects.
8 % 3. Replicate the values to the number of objects.
9 %
10 % CALL: [objs, values] = processSetterValues(objs, pls, rest, pName)
11 %
12 % IMPUTS: objs: Array of objects
13 % pls: Array of PLISTs or empty array
14 % rest: Cell-array with possible values
15 % pName: Property name of objs
16 %
17 % VERSION: $Id: processSetterValues.m,v 1.4 2011/09/17 03:09:37 hewitson Exp $
18 %
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20
21 function [objs, values] = processSetterValues(objs, pls, rest, pName)
22
23 % If pls contains only one plist with the single key of the property name
24 % then set the property with a plist.
25 if length(pls) == 1 && isa(pls, 'plist') && isparam(pls, pName)
26 rest{1} = find(pls, pName);
27 end
28
29 % Check if the user uses a cell-array for the different values
30 if numel(rest)==1 && iscell(rest{1})
31 rest = rest{1};
32 end
33
34 % Check the number of value
35 if numel(rest) > 1 && numel(rest) ~= numel(objs)
36 error('### Please specify one %s [n=%d] for each %s [n=%d], either in a plist or direct.', pName, numel(rest), upper(class(objs)), numel(objs));
37 end
38
39 % Replicate the values in 'rest' to the number of AOs
40 if numel(rest) == 1 && numel(objs) ~= 1
41 u = rest{1};
42 rest = cell(size(objs));
43 if isa(u, 'ltpda_obj')
44 rest = cellfun(@(x){copy(u, 1)}, rest);
45 else
46 rest(:) = {u};
47 end
48 end
49
50 values = rest;
51
52 end