comparison m-toolbox/classes/@pzmodel/setZeros.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 % SETZEROS Set the property 'zeros' of a pole/zero model.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: SETZEROS Set the property 'zeros' of a pole/zero model.
5 %
6 % CALL: obj = obj.setZeros(zeros);
7 %
8 % INPUTS: obj - is a pzmodel object
9 % zeros - cell-array --> {[f1,q1], f2, c3}
10 % comma separated --> [f1,q1], f2, c3
11 % zero-array --> [pz(f1,q1), pz(f2), pz(c3)]
12 %
13 % f: frequency
14 % [f,q]: frequency and Q
15 % c: complex representation
16 %
17 % EXAPLES: obj = obj.setZeros(3, [8 1]);
18 % obj = obj.setZeros(3, [8 1], 7);
19 % obj = obj.setZeros([pz(3), pz(8,1), pz(7)]);
20 % obj = setZeros(obj, pz(2));
21 %
22 % <a href="matlab:utils.helper.displayMethodInfo('pzmodel', 'setZeros')">Parameters Description</a>
23 %
24 % VERSION: $Id: setZeros.m,v 1.10 2011/08/15 12:02:36 hewitson Exp $
25 %
26 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28 function varargout = setZeros(varargin)
29
30 %%% Check if this is a call for parameters
31 if utils.helper.isinfocall(varargin{:})
32 varargout{1} = getInfo(varargin{3});
33 return
34 end
35
36 %%% Internal call: Only one object + don't look for a plist
37 if utils.helper.callerIsMethod
38
39 %%% decide whether we modify the first object, or create a new one.
40 varargin{1} = copy(varargin{1}, nargout);
41
42 for ii = 1:numel(varargin{1})
43 if ~isempty(varargin{2})
44 if isa(varargin{2}, 'pz')
45 varargin{1}(ii).zeros = [varargin{2:end}];
46 else
47 varargin{1}(ii).zeros = pz(varargin(2:end));
48 end
49 end
50 end
51 varargout{1} = varargin{1};
52 return
53 end
54
55 import utils.const.*
56 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
57
58 % Collect input variable names
59 in_names = cell(size(varargin));
60 for ii = 1:nargin,in_names{ii} = inputname(ii);end
61
62 % Collect all AOs
63 [as, ao_invars,rest] = utils.helper.collect_objects(varargin(:), 'ltpda_tf', in_names);
64 [pls, invars, rest] = utils.helper.collect_objects(rest(:), 'plist');
65
66 %%% If pls contains only one plist with the only key 'zeros' then set the
67 %%% property with a plist.
68 if length(pls) == 1 && isa(pls, 'plist') && nparams(pls) == 1 && isparam(pls, 'zeros')
69 rest = find(pls, 'zeros');
70 end
71
72 %%% Combine plists
73 if isempty(pls)
74 pls = plist('zeros', rest);
75 else
76 pls = pls.combine(plist('zeros', rest));
77 end
78
79 % Decide on a deep copy or a modify
80 bs = copy(as, nargout);
81
82 % Loop over AOs
83 for j=1:numel(bs)
84 if isa(rest{1}, 'pz')
85 bs(j).zeros = rest{1};
86 else
87 bs(j).zeros = pz(rest);
88 end
89 bs(j).addHistory(getInfo('None'), pls, ao_invars(j), bs(j).hist);
90 end
91
92 %%% Set output
93 if nargout == numel(bs)
94 % List of outputs
95 for ii = 1:numel(bs)
96 varargout{ii} = bs(ii);
97 end
98 else
99 % Single output
100 varargout{1} = bs;
101 end
102 end
103
104 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 % Local Functions %
106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
107 %--------------------------------------------------------------------------
108 % Get Info Object
109 %--------------------------------------------------------------------------
110 function ii = getInfo(varargin)
111
112 if nargin == 1 && strcmpi(varargin{1}, 'None')
113 sets = {};
114 pl = [];
115 else
116 sets = {'Default'};
117 pl = getDefaultPlist;
118 end
119 % Build info object
120 ii = minfo(mfilename, 'pzmodel', 'ltpda', utils.const.categories.helper, '$Id: setZeros.m,v 1.10 2011/08/15 12:02:36 hewitson Exp $', sets, pl);
121 end
122
123 %--------------------------------------------------------------------------
124 % Get Default Plist
125 %--------------------------------------------------------------------------
126 function plout = getDefaultPlist()
127 persistent pl;
128 if exist('pl', 'var')==0 || isempty(pl)
129 pl = buildplist();
130 end
131 plout = pl;
132 end
133
134 function pl = buildplist()
135 pl = plist();
136 % Zeros
137 p = param({'zeros', 'A zero-array of the model.'}, paramValue.EMPTY_DOUBLE);
138 pl.append(p);
139 end
140