Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/fromVals.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 % FROMVALS Construct an ao from a value set | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % FUNCTION: fromVals | |
5 % | |
6 % DESCRIPTION: Construct an ao from a value set | |
7 % | |
8 % CALL: a = fromVals(a, pli, callerIsMethod) | |
9 % | |
10 % PARAMETERS: | |
11 % N: Number of copies of the object to produce | |
12 % vals: Constant values | |
13 % | |
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
15 function a = fromVals(a, pli, callerIsMethod) | |
16 | |
17 VERSION = '$Id: fromVals.m,v 1.38 2011/08/16 04:57:59 hewitson Exp $'; | |
18 | |
19 if callerIsMethod | |
20 % do nothing | |
21 else | |
22 % get AO info | |
23 ii = ao.getInfo('ao', 'From Values'); | |
24 | |
25 % Set the method version string in the minfo object | |
26 ii.setMversion([VERSION '-->' ii.mversion]); | |
27 end | |
28 | |
29 % Combine input plist with default values | |
30 if callerIsMethod | |
31 pl = pli; | |
32 N = 1; | |
33 else | |
34 % Combine input plist with default values | |
35 % TODO: the parse step should be removed and included somehow into plist/applyDefaults | |
36 pl = applyDefaults(ii.plists, pli); | |
37 % Get values from the plist | |
38 N = find(pl, 'N'); | |
39 end | |
40 | |
41 | |
42 vals = find(pl, 'vals'); | |
43 | |
44 % Create an AO with cdata if no value is set | |
45 if isempty(vals) | |
46 vals = 0; | |
47 end | |
48 | |
49 % Set data | |
50 a.data = cdata(repmat(vals, 1, N)); | |
51 | |
52 if callerIsMethod | |
53 % do nothing | |
54 else | |
55 % Add history | |
56 a.addHistory(ii, pl, [], []); | |
57 end | |
58 | |
59 % Set yunits | |
60 a.setYunits(pl.find('yunits')); | |
61 | |
62 % Set any remaining object properties which exist in the default plist | |
63 a.setObjectProperties(pl); | |
64 | |
65 end | |
66 |