comparison m-toolbox/classes/@ao/setXunits.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 % SETXUNITS sets the 'xunits' property of the ao.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SETXUNITS sets the 'xunits' property of the ao.
5 %
6 % CALL: objs.setXunits(val);
7 % objs.setXunits(val1, val2);
8 % objs.setXunits(plist('xunits', val));
9 % objs = objs.setXunits(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', 'setXunits')">Parameters Description</a>
23 %
24 % VERSION: $Id: setXunits.m,v 1.28 2011/09/16 05:03:21 hewitson Exp $
25 %
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28 function varargout = setXunits(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 'xunits', ...
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 xunits
56 function value = setterFcn(varargin)
57
58 if nargin < 3
59 error('Please provide a value for the ''xunits'' property');
60 end
61
62 obj = varargin{1};
63 pl = varargin{2};
64 value = varargin{3};
65
66 obj.data.setXunits(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: setXunits.m,v 1.28 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({'xunits', 'The unit to set.'}, paramValue.EMPTY_STRING);
102 end