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