Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/setYunits.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 % SETYUNITS sets the 'yunits' property of the ao. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: SETYUNITS sets the 'yunits' property of the ao. | |
5 % | |
6 % CALL: objs.setYunits(val); | |
7 % objs.setYunits(val1, val2); | |
8 % objs.setYunits(plist('yunits', val)); | |
9 % objs = objs.setYunits(val); | |
10 % | |
11 % INPUTS: objs: Can be a vector, matrix, list, or a mix of them. | |
12 % val: | |
13 % 1. Single string e.g. 'Hz' | |
14 % Each AO in objs get this value. | |
15 % 2. Single string in a cell-array e.g. {'Hz'} | |
16 % Each AO in objs get this value. | |
17 % 3. cell-array with the same number of strings as in objs | |
18 % e.g. {'Hz', 'V', 's'} 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', 'setYunits')">Parameters Description</a> | |
23 % | |
24 % VERSION: $Id: setYunits.m,v 1.30 2011/09/16 05:03:21 hewitson Exp $ | |
25 % | |
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
27 | |
28 function varargout = setYunits(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 'yunits', ... | |
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 the yunits | |
56 function value = setterFcn(varargin) | |
57 | |
58 if nargin < 3 | |
59 error('Please provide a value for the ''yunits'' property'); | |
60 end | |
61 | |
62 obj = varargin{1}; | |
63 pl = varargin{2}; | |
64 value = varargin{3}; | |
65 | |
66 obj.data.setYunits(value); | |
67 | |
68 end | |
69 | |
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
71 % Local Functions % | |
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
73 %-------------------------------------------------------------------------- | |
74 % Get Info Object | |
75 %-------------------------------------------------------------------------- | |
76 function ii = getInfo(varargin) | |
77 | |
78 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
79 sets = {}; | |
80 pl = []; | |
81 else | |
82 sets = {'Default'}; | |
83 pl = getDefaultPlist(); | |
84 end | |
85 % Build info object | |
86 ii = minfo(mfilename, mfilename('class'), 'ltpda', utils.const.categories.helper, '$Id: setYunits.m,v 1.30 2011/09/16 05:03:21 hewitson Exp $', sets, pl); | |
87 end | |
88 | |
89 %-------------------------------------------------------------------------- | |
90 % Get Default Plist | |
91 %-------------------------------------------------------------------------- | |
92 function plout = getDefaultPlist() | |
93 persistent pl; | |
94 if ~exist('pl', 'var') || isempty(pl) | |
95 pl = buildplist(); | |
96 end | |
97 plout = pl; | |
98 end | |
99 | |
100 function pl = buildplist() | |
101 pl = plist({'yunits', 'The unit to set.'}, paramValue.EMPTY_STRING); | |
102 end |