Mercurial > hg > ltpda
comparison m-toolbox/classes/@filterbank/setIunits.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 % SETIUNITS sets the 'iunits' property of each filter-object inside the filterbank-object. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: SETIUNITS sets the 'iunits' property of each filter-object | |
5 % inside the filterbank-object. But only for 'parallel' | |
6 % filterbank-objects. | |
7 % | |
8 % CALL: objs.setIunits(val); | |
9 % objs.setIunits(val1, val2); | |
10 % objs.setIunits(plist('iunits', val)); | |
11 % objs = objs.setIunits(val); | |
12 % | |
13 % INPUTS: objs: Can be a vector, matrix, list, or a mix of them. | |
14 % val: | |
15 % 1. Single string e.g. 'Hz' | |
16 % Each filter-object inside the filterbank(objs) get this value. | |
17 % 2. Single string in a cell-array e.g. {'Hz'} | |
18 % Each filter-object inside the filterbank(objs) get this value. | |
19 % 3. cell-array with the same number of strings as in objs | |
20 % e.g. {'Hz', 'V', 's'} and 3 filterbank objects in objs | |
21 % Each filter-object inside the filterbank(objs) get | |
22 % its corresponding value from the cell-array | |
23 % | |
24 % <a href="matlab:utils.helper.displayMethodInfo('filterbank', 'setIunits')">Parameters Description</a> | |
25 % | |
26 % VERSION: $Id: setIunits.m,v 1.8 2011/09/17 03:09:26 hewitson Exp $ | |
27 % | |
28 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
29 | |
30 function varargout = setIunits(varargin) | |
31 | |
32 % Check if this is a call from a class method | |
33 callerIsMethod = utils.helper.callerIsMethod; | |
34 | |
35 if callerIsMethod | |
36 fb = varargin{1}; | |
37 values = varargin(2:end); | |
38 | |
39 else | |
40 % Check if this is a call for parameters | |
41 if utils.helper.isinfocall(varargin{:}) | |
42 varargout{1} = getInfo(varargin{3}); | |
43 return | |
44 end | |
45 | |
46 import utils.const.* | |
47 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename); | |
48 | |
49 % Collect input variable names | |
50 in_names = cell(size(varargin)); | |
51 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
52 | |
53 % Collect all filterbank objects | |
54 [fb, fb_invars, rest] = utils.helper.collect_objects(varargin(:), 'filterbank', in_names); | |
55 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist'); | |
56 | |
57 % Define property name | |
58 pName = 'iunits'; | |
59 | |
60 % Get values for the filterbank objects | |
61 [fb, values] = processSetterValues(fb, pls, rest, pName); | |
62 | |
63 % Combine input plists and default PLIST | |
64 pls = combine(pls, getDefaultPlist()); | |
65 | |
66 end % callerIsMethod | |
67 | |
68 % Decide on a deep copy or a modify | |
69 fb = copy(fb, nargout); | |
70 | |
71 for j=1:numel(fb) | |
72 if strcmpi(fb(j).type, 'parallel') | |
73 fb(j).filters.setIunits(values{j}); | |
74 if ~callerIsMethod | |
75 plh = pls.pset(pName, values{j}); | |
76 fb(j).addHistory(getInfo('None'), plh, fb_invars(j), fb(j).hist); | |
77 end | |
78 else | |
79 warning('LTPDA:FILTERBANK:SETIUNITS', '!!! Skip filterbank %s because it is not a parallel filterbank.', fb(j).name); | |
80 end | |
81 end | |
82 | |
83 % Set output | |
84 nObjs = numel(fb); | |
85 if nargout == nObjs; | |
86 % List of outputs | |
87 for ii = 1:nObjs | |
88 varargout{ii} = fb(ii); | |
89 end | |
90 else | |
91 % Single output | |
92 varargout{1} = fb; | |
93 end | |
94 end | |
95 | |
96 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
97 % Local Functions % | |
98 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
99 %-------------------------------------------------------------------------- | |
100 % Get Info Object | |
101 %-------------------------------------------------------------------------- | |
102 function ii = getInfo(varargin) | |
103 | |
104 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
105 sets = {}; | |
106 pl = []; | |
107 else | |
108 sets = {'Default'}; | |
109 pl = getDefaultPlist; | |
110 end | |
111 % Build info object | |
112 ii = minfo(mfilename, mfilename('class'), 'ltpda', utils.const.categories.helper, '$Id: setIunits.m,v 1.8 2011/09/17 03:09:26 hewitson Exp $', sets, pl); | |
113 end | |
114 | |
115 %-------------------------------------------------------------------------- | |
116 % Get Default Plist | |
117 %-------------------------------------------------------------------------- | |
118 function plout = getDefaultPlist() | |
119 persistent pl; | |
120 if exist('pl', 'var')==0 || isempty(pl) | |
121 pl = buildplist(); | |
122 end | |
123 plout = pl; | |
124 end | |
125 | |
126 function pl = buildplist() | |
127 pl = plist({'iunits', 'The unit to set.'}, paramValue.EMPTY_STRING); | |
128 end |