Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/setZ.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 % SETZ sets the 'z' property of the ao. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: SETZ sets the 'z' property of the ao. | |
5 % | |
6 % CALL: objs.setZ(val); | |
7 % objs.setZ(val1, val2); | |
8 % objs.setZ(plist('z', val)); | |
9 % objs = objs.setZ(val); | |
10 % | |
11 % INPUTS: objs: Can be a vector, matrix, list, or a mix of them. | |
12 % val: | |
13 % 1. Single vector e.g. [1 2 3] | |
14 % Each AO in objs get this value. | |
15 % 2. Single vector in a cell-array e.g. {[1 2 3]} | |
16 % Each AO in objs get this value. | |
17 % 3. cell-array with the same number of vectors as in objs | |
18 % e.g. {[6 5 4], 5, [1 2 3]} and 3 AOs in objs | |
19 % Each AO in objs get its corresponding value from the | |
20 % cell-array | |
21 % | |
22 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'setZ')">Parameters Description</a> | |
23 % | |
24 % VERSION: $Id: setZ.m,v 1.22 2011/09/16 05:03:21 hewitson Exp $ | |
25 % | |
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
27 | |
28 function varargout = setZ(varargin) | |
29 | |
30 % Check if this is a call from a class method | |
31 callerIsMethod = utils.helper.callerIsMethod; | |
32 | |
33 if callerIsMethod | |
34 in_names = {}; | |
35 else | |
36 % Collect input variable names | |
37 in_names = cell(size(varargin)); | |
38 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
39 end | |
40 | |
41 objects = setPropertyValue(... | |
42 varargin{:}, ... | |
43 in_names, ... | |
44 callerIsMethod, ... | |
45 'z', ... | |
46 @setterFcn, ... | |
47 nargout, ... | |
48 @getInfo); | |
49 | |
50 % set outputs | |
51 varargout = utils.helper.setoutputs(nargout, objects); | |
52 | |
53 end | |
54 | |
55 % Setter function to set z | |
56 function value = setterFcn(varargin) | |
57 | |
58 if nargin < 3 | |
59 error('Please provide a value for the ''z'' property'); | |
60 end | |
61 | |
62 obj = varargin{1}; | |
63 pl = varargin{2}; | |
64 value = varargin{3}; | |
65 | |
66 % be careful that the returned value remains an AO! | |
67 if isa(value, 'ao') | |
68 obj.data.setY(value.y); | |
69 else | |
70 obj.data.setY(value); | |
71 end | |
72 | |
73 end | |
74 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
75 % Local Functions % | |
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
77 %-------------------------------------------------------------------------- | |
78 % Get Info Object | |
79 %-------------------------------------------------------------------------- | |
80 function ii = getInfo(varargin) | |
81 | |
82 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
83 sets = {}; | |
84 pl = []; | |
85 else | |
86 sets = {'Default'}; | |
87 pl = getDefaultPlist(); | |
88 end | |
89 % Build info object | |
90 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.helper, '$Id: setZ.m,v 1.22 2011/09/16 05:03:21 hewitson Exp $', sets, pl); | |
91 end | |
92 | |
93 %-------------------------------------------------------------------------- | |
94 % Get Default Plist | |
95 %-------------------------------------------------------------------------- | |
96 function plout = getDefaultPlist() | |
97 persistent pl; | |
98 if ~exist('pl', 'var') || isempty(pl) | |
99 pl = buildplist(); | |
100 end | |
101 plout = pl; | |
102 end | |
103 | |
104 function pl = buildplist() | |
105 pl = plist({'z', 'A vector to set to the z field.'}, paramValue.EMPTY_DOUBLE); | |
106 end | |
107 |