Mercurial > hg > ltpda
comparison m-toolbox/classes/@pzmodel/fromPolesAndZeros.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 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
2 % | |
3 % FUNCTION: fromPolesAndZeros | |
4 % | |
5 % DESCRIPTION: Construct a pzmodel from poles and zeros | |
6 % | |
7 % CALL: pzm = fromPolesAndZeros(a, pl) | |
8 % | |
9 % PARAMETER: pl - plist | |
10 % | |
11 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
12 function pzm = fromPolesAndZeros(pzm, pli) | |
13 | |
14 VERSION = '$Id: fromPolesAndZeros.m,v 1.20 2011/08/15 10:10:33 hewitson Exp $'; | |
15 | |
16 | |
17 % get pzmodel info | |
18 ii = pzmodel.getInfo('pzmodel', 'From Poles/Zeros'); | |
19 | |
20 % Set the method version string in the minfo object | |
21 ii.setMversion([VERSION '-->' ii.mversion]); | |
22 | |
23 % Combine input plist with default values | |
24 pl = applyDefaults(ii.plists, pli); | |
25 | |
26 % Set fields | |
27 pzm.gain = find(pl, 'gain'); | |
28 ps = find(pl, 'poles'); | |
29 zs = find(pl, 'zeros'); | |
30 | |
31 % If the poles/zeros in the plist are no pz-objects then convert them | |
32 if ~isa(ps, 'pz') && ~isempty(ps) | |
33 ps = pz(ps); | |
34 end | |
35 if ~isa(zs, 'pz') && ~isempty(zs) | |
36 zs = pz(zs); | |
37 end | |
38 | |
39 % Add only valid poles | |
40 poles = []; | |
41 for kk = 1:numel(ps) | |
42 if ~isnan(ps(kk).f) | |
43 poles = [poles ps(kk)]; | |
44 end | |
45 end | |
46 pl.pset('poles', poles); | |
47 | |
48 % Add only valid zeros | |
49 zeros = []; | |
50 for kk = 1:numel(zs) | |
51 if ~isnan(zs(kk).f) | |
52 zeros = [zeros zs(kk)]; | |
53 end | |
54 end | |
55 pl.pset('zeros', zeros); | |
56 | |
57 % Set object properties from input plist | |
58 pzm.setObjectProperties(pl); | |
59 | |
60 % Add history | |
61 pzm.addHistory(ii, pl, [], []); | |
62 | |
63 end |