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