PZ is the ltpda class that provides a common definition of poles and zeros. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DESCRIPTION: PZ is the ltpda class that provides a common definition of poles and zeros. CONSTRUCTORS: p = pz(f) % specify frequency p = pz(f,q) % specify frequency and Q p = pz(c) % create with complex representation SUPER CLASSES: ltpda_nuo < ltpda_obj PROPERTIES: Inherit Properties (read only) version - cvs-version string. Protected Properties (read only) f - frequency of pole/zero q - quality factor of pole/zero ri - complex representation of pole/zero PZ METHODS: Defined Abstract methods: char - returns one character string which represents the object copy - copies an object display - displays an object update_struct - updates a object structure to the current tbx-version Public methods: cz2iir - return a,b IIR filter coefficients for a complex zero designed using the bilinear transform. cp2iir - return a,b IIR filter coefficients for a complex pole designed using the bilinear transform. rp2iir - return a,b coefficients for a real pole designed using the bilinear transform. rz2iir - return a,b IIR filter coefficients for a real zero designed using the bilinear transform. Protected methods: setF - set the frequency property setQ - set the quality factor setRI - set the complex form of the pole/zero ri2fq - convert comlpex pole/zero into frequency/Q pole/zero representation. fq2ri - convert frequency/Q pole/zero representation M-FILE INFO: The following call returns an minfo object that contains information about the pz constructor: >> info = pz.getInfo or >> info = pz.getInfo('pz') You can get information about class methods by calling: >> info = pz.getInfo(method) e.g. >> info = pz.getInfo('eq') You can also restrict the sets of parameters contained in the minfo object by calling: >> info = pz.getInfo(method, set) e.g. >> info = pz.getInfo('param', 'Default') VERSION: $Id: pz.m,v 1.23 2008/09/03 16:36:02 hewitson Exp $ HISTORY: 19-05-2008 Diepholz Creation. SEE ALSO: ltpda_obj, ltpda_nuo, pzmodel %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0001 % PZ is the ltpda class that provides a common definition of poles and zeros. 0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0003 % 0004 % DESCRIPTION: PZ is the ltpda class that provides a common definition of 0005 % poles and zeros. 0006 % 0007 % CONSTRUCTORS: 0008 % 0009 % p = pz(f) % specify frequency 0010 % p = pz(f,q) % specify frequency and Q 0011 % p = pz(c) % create with complex representation 0012 % 0013 % 0014 % SUPER CLASSES: ltpda_nuo < ltpda_obj 0015 % 0016 % PROPERTIES: 0017 % 0018 % Inherit Properties (read only) 0019 % version - cvs-version string. 0020 % 0021 % Protected Properties (read only) 0022 % f - frequency of pole/zero 0023 % q - quality factor of pole/zero 0024 % ri - complex representation of pole/zero 0025 % 0026 % PZ METHODS: 0027 % 0028 % Defined Abstract methods: 0029 % char - returns one character string which represents the object 0030 % copy - copies an object 0031 % display - displays an object 0032 % update_struct - updates a object structure to the current tbx-version 0033 % 0034 % Public methods: 0035 % cz2iir - return a,b IIR filter coefficients for a complex zero designed 0036 % using the bilinear transform. 0037 % cp2iir - return a,b IIR filter coefficients for a complex pole designed 0038 % using the bilinear transform. 0039 % rp2iir - return a,b coefficients for a real pole designed using the 0040 % bilinear transform. 0041 % rz2iir - return a,b IIR filter coefficients for a real zero designed using 0042 % the bilinear transform. 0043 % 0044 % Protected methods: 0045 % setF - set the frequency property 0046 % setQ - set the quality factor 0047 % setRI - set the complex form of the pole/zero 0048 % ri2fq - convert comlpex pole/zero into frequency/Q pole/zero representation. 0049 % fq2ri - convert frequency/Q pole/zero representation 0050 % 0051 % M-FILE INFO: The following call returns an minfo object that contains 0052 % information about the pz constructor: 0053 % >> info = pz.getInfo 0054 % or >> info = pz.getInfo('pz') 0055 % 0056 % You can get information about class methods by calling: 0057 % >> info = pz.getInfo(method) 0058 % e.g. >> info = pz.getInfo('eq') 0059 % 0060 % You can also restrict the sets of parameters contained in 0061 % the minfo object by calling: 0062 % >> info = pz.getInfo(method, set) 0063 % e.g. >> info = pz.getInfo('param', 'Default') 0064 % 0065 % VERSION: $Id: pz.m,v 1.23 2008/09/03 16:36:02 hewitson Exp $ 0066 % 0067 % HISTORY: 19-05-2008 Diepholz 0068 % Creation. 0069 % 0070 % SEE ALSO: ltpda_obj, ltpda_nuo, pzmodel 0071 % 0072 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0073 0074 classdef pz < ltpda_nuo 0075 0076 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0077 % Property definition % 0078 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0079 0080 %---------- Public (read/write) Properties ---------- 0081 properties 0082 end 0083 0084 %---------- Protected read-only Properties ---------- 0085 properties (SetAccess = protected) 0086 f = NaN; 0087 q = NaN; 0088 ri = NaN; 0089 version = '$Id: pz.m,v 1.23 2008/09/03 16:36:02 hewitson Exp $'; 0090 end 0091 0092 %---------- Private Properties ---------- 0093 properties (GetAccess = protected, SetAccess = protected) 0094 end 0095 0096 %---------- Abstract Properties ---------- 0097 properties (Abstract = true, SetAccess = protected) 0098 end 0099 0100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0101 % Check property setting % 0102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0103 0104 methods 0105 function obj = set.f(obj, val) 0106 if ~isnumeric(val) || isempty(val) || ~isreal(val) 0107 error('### The value for the property ''f'' must be a real positive number'); 0108 end 0109 obj.f = val; 0110 end 0111 function obj = set.q(obj, val) 0112 if ~isnumeric(val) || isempty(val) || ~isreal(val) 0113 error('### The value for the property ''q'' must be a real positive number'); 0114 end 0115 obj.q = val; 0116 end 0117 function obj = set.ri(obj, val) 0118 if ~isnumeric(val) || isempty(val) 0119 error('### The value for the property ''ri'' must be a number'); 0120 end 0121 obj.ri = val; 0122 end 0123 end 0124 0125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0126 % Constructor % 0127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0128 0129 methods 0130 function obj = pz(varargin) 0131 0132 %%% Call superclass 0133 obj = obj@ltpda_nuo(varargin{:}); 0134 0135 %%%%%%%%%% Set dafault values %%%%%%%%%% 0136 0137 if nargin == 0 0138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0139 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% no inputs %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0141 0142 elseif nargin == 1 0143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% one input %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0146 0147 if isa(varargin{1}, 'pz') 0148 %%%%%%%%%% Copy ltpda_obj Object %%%%%%%%%% 0149 %%%%%%%%%% p1 = pz(pz-object) %%%%%%%%%% 0150 obj = copy(varargin{1}, 1); 0151 0152 elseif isnumeric(varargin{1}) 0153 %%%%%%%%%% real or complex pole/zero %%%%%%%%%% 0154 if length(varargin{1}) == 1 0155 if isreal(varargin{1}) 0156 %%%%%%%%%% p1 = pz(3) %%%%%%%%%% 0157 obj.setF(varargin{1}); 0158 obj.setQ(NaN); 0159 else 0160 %%%%%%%%%% p1 = pz(1+3i) %%%%%%%%%% 0161 obj.setRI(varargin{1}); 0162 end 0163 elseif length(varargin{1}) == 2 0164 %%%%%%%%%% p1 = pz([1 2]) %%%%%%%%%% 0165 obj.setF(varargin{1}(1)); 0166 obj.setQ(varargin{1}(2)); 0167 else 0168 error('### Unknown constructor for the input %s', mat2str(varargin{1})); 0169 end 0170 0171 elseif isa(varargin{1}, 'plist') 0172 %%%%%%%%%% p1 = pz(plist-object) %%%%%%%%%% 0173 pl = varargin{1}; 0174 f = find(pl, 'f'); 0175 q = find(pl, 'q'); 0176 ri = find(pl, 'ri'); 0177 if ~isempty(f) 0178 obj.setF(f); 0179 if ~isempty(q) 0180 obj.setQ(q); 0181 end 0182 elseif ~isempty(ri) 0183 obj.setRI(ri); 0184 else 0185 error('### Unknown plist constructor'); 0186 end 0187 0188 elseif isstruct(varargin{1}) 0189 %%%%%%%%%% p1 = pz(structure) %%%%%%%%%% 0190 %%% Set properties which are declared in this class 0191 obj.f = varargin{1}.f; 0192 obj.q = varargin{1}.q; 0193 obj.ri = varargin{1}.ri; 0194 obj.version = varargin{1}.version; 0195 0196 elseif iscell(varargin{1}) 0197 %%%%%%%%%% p1 = pz({[1 2], 1+2i, 3}) %%%%%%%%%% 0198 obj(1:numel(varargin{1})) = pz(); 0199 for kk = 1:numel(varargin{1}) 0200 obj(kk) = pz(varargin{1}{kk}); 0201 end 0202 0203 else 0204 error('### Unknown call of the pz constructor.'); 0205 end 0206 0207 elseif nargin == 2 0208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0209 %%%%%%%%%%%%%%%%%%%%%%%%%%%%% one input %%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0211 0212 %%%%%%%%%% obj = pz(f, q) %%%%%%%%%% 0213 % f,q constructor 0214 obj.setF(varargin{1}); 0215 obj.setQ(varargin{2}); 0216 else 0217 error('### Unknown number of arguments.'); 0218 end 0219 0220 end 0221 0222 end 0223 0224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0225 % Methods (public) % 0226 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0227 0228 methods 0229 varargout = cp2iir(varargin) 0230 varargout = cz2iir(varargin) 0231 varargout = rz2iir(varargin) 0232 varargout = rp2iir(varargin) 0233 end 0234 0235 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0236 % Methods (protected) % 0237 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0238 0239 methods (Access = protected) 0240 ii = setF(ii, val) 0241 ii = setQ(ii, val) 0242 ii = setRI(ii, val) 0243 end 0244 0245 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0246 % Methods (public) % 0247 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0248 0249 methods 0250 varargout = copy(varargin) 0251 [f,r] = resp(varargin) 0252 varargout = string(varargin) 0253 end 0254 0255 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0256 % Methods (protected, static) % 0257 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0258 0259 methods( Access = protected, Static) 0260 [f0, q] = ri2fq(c); 0261 ri = fq2ri(f0, Q); 0262 end 0263 0264 0265 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0266 % Methods (static) % 0267 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0268 0269 methods (Static) 0270 0271 varargout = update_struct(varargin); 0272 0273 function out = VEROUT() 0274 out = '$Id: pz.m,v 1.23 2008/09/03 16:36:02 hewitson Exp $'; 0275 end 0276 0277 function ii = getInfo(varargin) 0278 ii = utils.helper.generic_getInfo(varargin{:}, 'pz'); 0279 end 0280 0281 function out = SETS() 0282 out = {'Default'}; 0283 end 0284 0285 function out = getDefaultPlist(set) 0286 switch set 0287 case 'Default' 0288 out = plist(); 0289 otherwise 0290 out = plist(); 0291 end 0292 end 0293 0294 end 0295 0296 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0297 % Methods (Static, Private) % 0298 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0299 0300 methods (Static = true, Access = private) 0301 end 0302 0303 end % End classdef