comparison m-toolbox/html_help/help/ug/constructor_examples_miir.html @ 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 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
3
4 <html lang="en">
5 <head>
6 <meta name="generator" content=
7 "HTML Tidy for Mac OS X (vers 1st December 2004), see www.w3.org">
8 <meta http-equiv="Content-Type" content=
9 "text/html; charset=us-ascii">
10
11 <title>Constructor examples of the MIIR class (LTPDA Toolbox)</title>
12 <link rel="stylesheet" href="docstyle.css" type="text/css">
13 <meta name="generator" content="DocBook XSL Stylesheets V1.52.2">
14 <meta name="description" content=
15 "Presents an overview of the features, system requirements, and starting the toolbox.">
16 </head>
17
18 <body>
19 <a name="top_of_page" id="top_of_page"></a>
20
21 <p style="font-size:1px;">&nbsp;</p>
22
23 <table class="nav" summary="Navigation aid" border="0" width=
24 "100%" cellpadding="0" cellspacing="0">
25 <tr>
26 <td valign="baseline"><b>LTPDA Toolbox</b></td><td><a href="../helptoc.html">contents</a></td>
27
28 <td valign="baseline" align="right"><a href=
29 "constructor_examples_mfir.html"><img src="b_prev.gif" border="0" align=
30 "bottom" alt="Constructor examples of the MFIR class"></a>&nbsp;&nbsp;&nbsp;<a href=
31 "constructor_examples_pzmodel.html"><img src="b_next.gif" border="0" align=
32 "bottom" alt="Constructor examples of the PZMODEL class"></a></td>
33 </tr>
34 </table>
35
36 <h1 class="title"><a name="f3-12899" id="f3-12899"></a>Constructor examples of the MIIR class</h1>
37 <hr>
38
39 <p>
40
41 <!-- -------------------------------------------------- -->
42 <!-- --------------- BEGIN CONTENT FILE --------------- -->
43 <!-- -------------------------------------------------- -->
44
45 <!-- --------------- Link box: begin --------------- -->
46 <table border="0" summary="Simple list" class="simplelist_nottable_last">
47 <tr>
48 <td>
49 <a href="constructor_examples_miir.html#empty">Copy a MIIR object</a>
50 </td>
51 </tr>
52 <tr>
53 <td>
54 <a href="constructor_examples_miir.html#xml_file">Construct a MIIR object by loading the object from a file</a>
55 </td>
56 </tr>
57 <tr>
58 <td>
59 <a href="constructor_examples_miir.html#parfrac">Construct a MIIR object from a parfrac object <tt>(PARFRAC)</tt></a>
60 </td>
61 </tr>
62 <tr>
63 <td>
64 <a href="constructor_examples_miir.html#pzmodel">Construct a MIIR object from a pole/zero model <tt>(PZMODEL)</tt></a>
65 </td>
66 </tr>
67 <tr>
68 <td>
69 <a href="constructor_examples_miir.html#std_type">Construct a MIIR object from a standard type</a>
70 </td>
71 </tr>
72 <tr>
73 <td>
74 <a href="constructor_examples_miir.html#exist_model">Construct a MIIR object from an existing model</a>
75 </td>
76 </tr>
77 <tr>
78 <td>
79 <a href="constructor_examples_miir.html#equation">Construct a MIIR object from a difference equation</a>
80 </td>
81 </tr>
82 </table>
83 <!-- --------------- Link box: end --------------- -->
84
85 <!-- --------------- NEXT EXAMPLE --------------- -->
86
87 <hr>
88 <h2 class="title"><a name="copy"></a>Copy an IIR filter object</h2>
89 <p>The following example creates a copy of an IIR filter object (blue command).</p>
90 <div class="fragment"><pre class="programlisting">
91 >> iir1 = miir(plist(<span class="string">'type'</span>, <span class="string">'lowpass'</span>));
92 <span class="blue">>> iir2 = miir(iir2)</span>
93 ------ miir/1 -------
94 b: [1 -0.509525449494429]
95 histin: 0
96 version: $Id: miir.m,v 1.98 2009/02/20 15:59:48 nicola Exp
97 ntaps: 2
98 fs: 1
99 infile:
100 a: [0.245237275252786 0.245237275252786]
101 histout: 0
102 iunits: [] [1x1 unit]
103 ounits: [] [1x1 unit]
104 hist: miir.hist [1x1 history]
105 name: lowpass
106 ---------------------
107 </pre></div>
108 <br></br>
109 <p>REMARK: The following command copies only the handle of an object and doesn't create a copy of the object (as above). This means that everything that happens to the copy or original happens to the other object.</p>
110 <div class="fragment"><pre class="programlisting">
111 >> iir1 = miir()
112 ------ miir/1 -------
113 b: []
114 histin: []
115 version: $Id: miir.m,v 1.98 2009/02/20 15:59:48 nicola Exp
116 ntaps: 0
117 fs: []
118 infile:
119 a: []
120 histout: []
121 iunits: [] [1x1 unit]
122 ounits: [] [1x1 unit]
123 hist: miir.hist [1x1 history]
124 name: none
125 ---------------------
126 >> iir2 = iir1;
127 >> iir2.setName(<span class="string">'my new name'</span>)
128 ------ miir/1 -------
129 b: []
130 histin: []
131 version: $Id: miir.m,v 1.98 2009/02/20 15:59:48 nicola Exp
132 ntaps: 0
133 fs: []
134 infile:
135 a: []
136 histout: []
137 iunits: [] [1x1 unit]
138 ounits: [] [1x1 unit]
139 hist: miir.hist [1x1 history]
140 name: <span class="string">my new name</span>
141 ---------------------
142 </pre></div>
143 <br></br>
144 <p>If we display iir1 again then we see that the property 'name' was changed although we only have changed iir2.</p>
145 <div class="fragment"><pre class="programlisting">
146 >> iir1
147 ------ miir/1 -------
148 b: []
149 histin: []
150 version: $Id: miir.m,v 1.98 2009/02/20 15:59:48 nicola Exp
151 ntaps: 0
152 fs: []
153 infile:
154 a: []
155 histout: []
156 iunits: [] [1x1 unit]
157 ounits: [] [1x1 unit]
158 hist: miir.hist [1x1 history]
159 name: <span class="string">my new name</span>
160 ---------------------
161 </pre></div>
162
163
164 <!-- --------------- NEXT EXAMPLE --------------- -->
165
166 <hr>
167 <h2 class="title"><a name="xml_file"></a>Construct a MIIR object by loading the object from a file</h2>
168 <p>The following example creates a new miir object by loading the miir object from disk.</p>
169 <div class="fragment"><pre class="programlisting">
170 f = miir(<span class="string">'f.mat'</span>)
171 f = miir(<span class="string">'f.xml'</span>)
172 </pre></div>
173 <p>or in a <tt>PLIST</tt></p>
174 <div class="fragment"><pre class="programlisting">
175 pl = plist(<span class="string">'filename'</span>, <span class="string">'iir.xml'</span>);
176 iir = miir(pl)
177 </pre></div>
178
179
180 <!-- --------------- NEXT EXAMPLE --------------- -->
181
182 <hr>
183 <h2 class="title"><a name="parfrac"></a>Construct a MIIR object from a parfrac object</h2>
184 <p> An IIR filter object can be generated based on a parfrac object. The next example shows how you can convert a parfrac object into a iir filter object.</p>
185 <div class="fragment"><pre class="programlisting">
186 pf = parfrac([1 2+1i 2-1i], [6 1+3i 1-3i], 3);
187 iir = miir(pf)
188 </pre></div>
189 <p>or in a PLIST with the relevant parameters:</p>
190 <p>
191 <table cellspacing="0" border="0" cellpadding="2" class="simplelist_nottable_last" width="80%">
192 <colgroup>
193 <col width="25%"/>
194 <col width="75%"/>
195 </colgroup>
196 <thead>
197 <tr valign="top">
198 <th class="subcategorylist">Key</th>
199 <th class="subcategorylist">Description</th>
200 </tr>
201 </thead>
202 <tbody>
203 <tr valign="top">
204 <td>
205 <p>'parfrac'</p>
206 </td>
207 <td>
208 <p>a parfrac object to construct the filters from [default: empty parfrac]</p>
209 </td>
210 </tr>
211 <tr valign="top">
212 <td>
213 <p>'fs'</p>
214 </td>
215 <td>
216 <p>sample rate for the filter(s) [default: 8 * upper frequency of the parfrac object]</p>
217 </td>
218 </tr>
219 </tbody>
220 </table>
221 </p>
222 <p>The following example creates a IIR filter object from an parfrac object.</p>
223 <div class="fragment"><pre class="programlisting">
224 pf = parfrac([1 2+1i 2-1i], [6 1+3i 1-3i], 3);
225 pl = plist(<span class="string">'parfrac'</span>, pf, <span class="string">'fs'</span>, 100);
226 </pre></div>
227
228
229 <!-- --------------- NEXT EXAMPLE --------------- -->
230
231
232 <hr>
233 <h2 class="title"><a name="pzmodel"></a>Construct an IIR filter object from a pole/zero model</h2>
234 <p>The following example creates a new IIR filter object from a pole/zero model.</p>
235 <div class="fragment"><pre class="programlisting">
236 >> pzm = pzmodel(1, {1 2 3}, {4 5}, <span class="string">'my pzmodel'</span>)
237 ---- pzmodel 1 ----
238 name: my pzmodel
239 gain: 1
240 delay: 0
241 iunits: []
242 ounits: []
243 pole 001: (f=1 Hz,Q=NaN)
244 pole 002: (f=2 Hz,Q=NaN)
245 pole 003: (f=3 Hz,Q=NaN)
246 zero 001: (f=4 Hz,Q=NaN)
247 zero 002: (f=5 Hz,Q=NaN)
248 -------------------
249 >> iir = miir(pzm) <span class="comment">% Use the default sample rate fs=8 * frequency of the highest pole or zero in the model</span>
250 >> iir = miir(pzm, plist(<span class="string">'fs'</span>, 100))
251 ------ miir/1 -------
252 b: [1 -0.6485 -1.9619 1.3364 0.9644 -0.6854]
253 histin: [0 0 0 0 0]
254 version: $Id: miir.m,v 1.98 2009/02/20 15:59:48 nicola Exp
255 ntaps: 6
256 fs: 100
257 infile:
258 a: [0.0102 0.0152 -0.0097 -0.0186 0.0019 0.0057]
259 histout: [0 0 0 0 0]
260 iunits: [] [1x1 unit]
261 ounits: [] [1x1 unit]
262 hist: miir.hist [1x1 history]
263 name: my pzmodel
264 ---------------------
265 </pre></div>
266 <p>or in a PLIST with the relevant parameters:</p>
267 <p>
268 <table cellspacing="0" border="0" cellpadding="2" class="simplelist_nottable_last" width="80%">
269 <colgroup>
270 <col width="25%"/>
271 <col width="75%"/>
272 </colgroup>
273 <thead>
274 <tr valign="top">
275 <th class="subcategorylist">Key</th>
276 <th class="subcategorylist">Description</th>
277 </tr>
278 </thead>
279 <tbody>
280 <tr valign="top">
281 <td>
282 <p>'pzmodel'</p>
283 </td>
284 <td>
285 <p>A pzmodel object to construct the filter from [default: empty pzmodel]</p>
286 </td>
287 </tr>
288 <tr valign="top">
289 <td>
290 <p>'fs'</p>
291 </td>
292 <td>
293 <p>Sample rate [default: 8 * frequency of the highest pole or zero in the model]</p>
294 </td>
295 </tr>
296 </tbody>
297 </table>
298 </p>
299 <div class="fragment"><pre class="programlisting">
300 >> pzm = pzmodel(1, {1 2 3}, {4 5}, <span class="string">'my pzmodel'</span>)
301 >> pl = plist(<span class="string">'pzmodel'</span>, pzm, <span class="string">'fs'</span>, 100)
302 >> iir = miir(pl)
303 </pre></div>
304
305
306 <!-- --------------- NEXT EXAMPLE --------------- -->
307
308
309 <hr></hr>
310 <h2 class="title"><a name="std_type"></a>Construct a MIIR object from a standard type</h2>
311 <p>Construct an IIR filter object from a standard type: 'lowpass', 'highpass', 'bandpass' or 'bandreject'</p>
312 <p>The relevant parameters are:</p>
313 <p>
314 <table cellspacing="0" border="0" cellpadding="2" class="simplelist_nottable_last" width="80%">
315 <colgroup>
316 <col width="25%"/>
317 <col width="75%"/>
318 </colgroup>
319 <thead>
320 <tr valign="top">
321 <th class="subcategorylist">Key</th>
322 <th class="subcategorylist">Description</th>
323 </tr>
324 </thead>
325 <tbody>
326 <tr valign="top">
327 <td>
328 <p>'type'</p>
329 </td>
330 <td>
331 <p>one of the types: 'highpass', 'lowpass', 'bandpass', 'bandreject'<br></br>
332 [default 'lowpass']</p>
333 </td>
334 </tr>
335 </tbody>
336 </table>
337 </p>
338 <p>You can also specify optional parameters:</p>
339 <p>
340 <table cellspacing="0" border="0" cellpadding="2" class="simplelist_nottable_last" width="80%">
341 <colgroup>
342 <col width="25%"/>
343 <col width="75%"/>
344 </colgroup>
345 <thead>
346 <tr valign="top">
347 <th class="subcategorylist">Key</th>
348 <th class="subcategorylist">Description</th>
349 </tr>
350 </thead>
351 <tbody>
352 <tr valign="top">
353 <td>
354 <p>'gain'</p>
355 </td>
356 <td>
357 <p>The gain of the filter [default: 1]</p>
358 </td>
359 </tr>
360 <tr valign="top">
361 <td>
362 <p>'fc'</p>
363 </td>
364 <td>
365 <p>The roll-off frequency [default: 0.1 Hz]</p>
366 </td>
367 </tr>
368 <tr valign="top">
369 <td>
370 <p>'fs'</p>
371 </td>
372 <td>
373 <p>The sampling frequency to design for [default: 1 Hz]</p>
374 </td>
375 </tr>
376 <tr valign="top">
377 <td>
378 <p>'order'</p>
379 </td>
380 <td>
381 <p>The filter order [default: 64]</p>
382 </td>
383 </tr>
384 <tr valign="top">
385 <td>
386 <p>'win'</p>
387 </td>
388 <td>
389 <p>Specify window function used in filter design [default: 'Hamming']</p>
390 </td>
391 </tr>
392 <tr valign="top">
393 <td>
394 <p>'iunits'</p>
395 </td>
396 <td>
397 <p>the input unit of the filter</p>
398 </td>
399 </tr>
400 <tr valign="top">
401 <td>
402 <p>'ounits'</p>
403 </td>
404 <td>
405 <p>the output unit of the filter</p>
406 </td>
407 </tr>
408 </tbody>
409 </table>
410 </p>
411 <p>The following example creates an order 64 highpass filter with high frequency gain 2. Filter is designed for 1 Hz sampled data and has a cut-off frequency of 0.2 Hz.</p>
412 <div class="fragment"><pre class="programlisting">
413 pl = plist(<span class="string">'type'</span>, <span class="string">'highpass'</span>, ...
414 <span class="string">'order'</span>, 64, ...
415 <span class="string">'gain'</span>, 2.0, ...
416 <span class="string">'fs'</span>, 1, ...
417 <span class="string">'fc'</span>, 0.2);
418 f = miir(pl)
419 </pre></div>
420 <p>Furthermore it is possible to specify a spectral window.</p>
421 <div class="fragment"><pre class="programlisting">
422 win = specwin(<span class="string">'Kaiser'</span>, 11, 150);
423 pl = plist(<span class="string">'type'</span>, <span class="string">'lowpass'</span>, ...
424 <span class="string">'Win'</span>, win, ...
425 <span class="string">'fs'</span>, 100, ...
426 <span class="string">'fc'</span>, 20, ...
427 <span class="string">'order'</span>, 10);
428 f = miir(pl)
429 </pre></div>
430
431
432 <!-- --------------- NEXT EXAMPLE --------------- -->
433
434
435 <hr>
436 <h2 class="title"><a name="exist_model"></a>Construct a MIIR object from an existing model</h2>
437 <p>The miir constructor also accepts as an input existing models in different formats:</p>
438 <p>LISO files</p>
439 <div class="fragment"><pre class="programlisting">
440 f = miir(<span class="string">'foo_iir.fil'</span>)
441 </pre></div>
442 <p>XML files</p>
443 <div class="fragment"><pre class="programlisting">
444 f = miir(<span class="string">'foo_iir.xml'</span>)
445 </pre></div>
446 <p>MAT files</p>
447 <div class="fragment"><pre class="programlisting">
448 f = miir(<span class="string">'foo_iir.mat'</span>)
449 </pre></div>
450 <p>From repository</p>
451 <p>The relevant parameters for retrieving a IIR filter from a LTPDA repository are:</p>
452 <p>
453 <table cellspacing="0" border="0" cellpadding="2" class="simplelist_nottable_last" width="80%">
454 <colgroup>
455 <col width="25%"/>
456 <col width="75%"/>
457 </colgroup>
458 <thead>
459 <tr valign="top">
460 <th class="subcategorylist">Key</th>
461 <th class="subcategorylist">Description</th>
462 </tr>
463 </thead>
464 <tbody>
465 <tr valign="top">
466 <td>
467 <p>'hostname'</p>
468 </td>
469 <td>
470 <p>the repository hostname. [default: 'localhost']</p>
471 </td>
472 </tr>
473 <tr valign="top">
474 <td>
475 <p>'database'</p>
476 </td>
477 <td>
478 <p>The database name [default: 'ltpda']</p>
479 </td>
480 </tr>
481 <tr valign="top">
482 <td>
483 <p>'id'</p>
484 </td>
485 <td>
486 <p>A vector of object IDs. [default: []]</p>
487 </td>
488 </tr>
489 <tr valign="top">
490 <td>
491 <p>'cid'</p>
492 </td>
493 <td>
494 <p>Retrieve all rational objects from a particular collection</p>
495 </td>
496 </tr>
497 <tr valign="top">
498 <td>
499 <p>'binary'</p>
500 </td>
501 <td>
502 <p>Set to 'yes' to retrieve from stored binary representation (not always available). [default: yes]</p>
503 </td>
504 </tr>
505 </tbody>
506 </table>
507 </p>
508 <div class="fragment"><pre class="programlisting">
509 f = miir(plist(<span class="string">'hostname'</span>, <span class="string">'localhost'</span>, <span class="string">'database'</span>, <span class="string">'ltpda'</span>, <span class="string">'ID'</span>, []))
510 </pre></div>
511
512
513 <!-- --------------- NEXT EXAMPLE --------------- -->
514
515 <hr>
516 <h2 class="title"><a name="equation"></a>Construct a MIIR object from a difference equation</h2>
517 <p>Alternatively, the filter can be defined in terms of two vectors specifying the coefficients of the filter and the sampling frequency. The following example creates a IIR filter with sampling frequency 1 Hz and the following recursive equation:</p>
518 <div align="center">
519 <IMG src="images/sigproc_9.png" width="299" height="28" align="middle" border="0">
520 </div>
521 <div class="fragment"><pre class="programlisting">
522 a = [0.5 -0.01];
523 b = [1 0.1]
524 fs = 1;
525
526 f = miir(a,b,fs)
527 </pre></div>
528 <p>or in a <tt>PLIST</tt></p>
529 <p>The relevant parameters are:</p>
530 <p>
531 <table cellspacing="0" border="0" cellpadding="2" class="simplelist_nottable_last" width="80%">
532 <colgroup>
533 <col width="25%"/>
534 <col width="75%"/>
535 </colgroup>
536 <thead>
537 <tr valign="top">
538 <th class="subcategorylist">Key</th>
539 <th class="subcategorylist">Description</th>
540 </tr>
541 </thead>
542 <tbody>
543 <tr valign="top">
544 <td>
545 <p>'a'</p>
546 </td>
547 <td>
548 <p>vector of A coefficients (see note ** below) [default: empty]</p>
549 </td>
550 </tr>
551 <tr valign="top">
552 <td>
553 <p>'b'</p>
554 </td>
555 <td>
556 <p>vector of B coefficients (see note ** below) [default: empty]</p>
557 </td>
558 </tr>
559 <tr valign="top">
560 <td>
561 <p>'fs'</p>
562 </td>
563 <td>
564 <p>sampling frequency of the filter [default: empty]</p>
565 </td>
566 </tr>
567 <tr valign="top">
568 <td>
569 <p>'name'</p>
570 </td>
571 <td>
572 <p>name of filter [default: 'None']</p>
573 </td>
574 </tr>
575 </tbody>
576 </table>
577 </p>
578 <div class="fragment"><pre class="programlisting">
579 a = [0.5 -0.01];
580 b = [1 0.1]
581 fs = 1;
582 name = <span class="string">'my IIR'</span>;
583 pl = plist(<span class="string">'a'</span>, a, <span class="string">'fs'</span>, fs, <span class="string">'name'</span>, name);
584
585 iir = miir(pl)
586 </pre></div>
587 <br></br>
588 <div class="fragment">
589 NOTES:<br></br>
590 ** The convention used here for naming the filter coefficients is the opposite to MATLAB's convention. The recursion formula for this convention is<br></br>
591 b(1)*y(n) = a(1)*x(n) + a(2)*x(n-1) + ... + a(na+1)*x(n-na) - b(2)*y(n-1) - ... - b(nb+1)*y(n-nb)
592 </div>
593
594 <!-- ------------------------------------------------ -->
595 <!-- --------------- END CONTENT FILE --------------- -->
596 <!-- ------------------------------------------------ -->
597
598 </p>
599
600 <br>
601 <br>
602 <table class="nav" summary="Navigation aid" border="0" width=
603 "100%" cellpadding="0" cellspacing="0">
604 <tr valign="top">
605 <td align="left" width="20"><a href="constructor_examples_mfir.html"><img src=
606 "b_prev.gif" border="0" align="bottom" alt=
607 "Constructor examples of the MFIR class"></a>&nbsp;</td>
608
609 <td align="left">Constructor examples of the MFIR class</td>
610
611 <td>&nbsp;</td>
612
613 <td align="right">Constructor examples of the PZMODEL class</td>
614
615 <td align="right" width="20"><a href=
616 "constructor_examples_pzmodel.html"><img src="b_next.gif" border="0" align=
617 "bottom" alt="Constructor examples of the PZMODEL class"></a></td>
618 </tr>
619 </table><br>
620
621 <p class="copy">&copy;LTP Team</p>
622 </body>
623 </html>