comparison m-toolbox/classes/@miir/fromPzmodel.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 % Construct an miir from a pzmodel
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % FUNCTION: fromPzmodel
5 %
6 % DESCRIPTION: Construct an miir from a pzmodel
7 %
8 % CALL: f = fromPzmodel(f, pli)
9 %
10 % PARAMETER: type: String with filter type description
11 % pli: Parameter list object
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14 function f = fromPzmodel(f, ipzm, pli)
15
16 VERSION = '$Id: fromPzmodel.m,v 1.16 2011/08/15 11:22:36 hewitson Exp $';
17 ii = miir.getInfo('miir', 'From Pzmodel');
18 % Set the method version string in the minfo object
19 ii.setMversion([VERSION '-->' ii.mversion]);
20
21 % Add default values
22 pl = applyDefaults(ii.plists, pli);
23
24 % Get parameters
25 if isempty(ipzm)
26 pzm = find(pl, 'pzmodel');
27 else
28 pzm = ipzm;
29 pl.remove('pzmodel');
30 end
31
32 if ~isa(pzm, 'pzmodel')
33 error('### The ''From Pzmodel'' constructor requires an input pzmodel');
34 end
35
36 fs = find(pl, 'fs');
37
38 if isempty(fs)
39 % get max freq in pzmodel
40 fs = 8*getupperFreq(pzm);
41 warning([sprintf('!!! no sample rate specified. Designing for fs=%2.2f Hz.', fs)...
42 sprintf('\nThe filter will be redesigned later when used.')]);
43 end
44 % make MIIR filter
45 f = tomiir(pzm, fs);
46
47 if isempty(pl.find('name'))
48 pl.pset('name', sprintf('iir(%s)', pzm.name));
49 end
50 if isempty(pl.find('description'))
51 pl.pset('description', pzm.description);
52 end
53 if isempty(pl.find('iunits'))
54 pl.pset('iunits', pzm.iunits);
55 end
56 if isempty(pl.find('ounits'))
57 pl.pset('ounits', pzm.ounits);
58 end
59
60 % Add history
61 if isempty(ipzm)
62 f.addHistory(ii, pl, [], []);
63 else
64 f.addHistory(ii, pl, [], ipzm.hist);
65 end
66
67 % Set object properties
68 f.setObjectProperties(pl);
69
70 end % End fromPzmodel