3430
|
1 ## Copyright (C) 1996 Auburn University. All rights reserved. |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
3430
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {[@var{c}, @var{tsam}, @var{input}, @var{output}] =} sys2fir (@var{sys}) |
|
22 ## |
5016
|
23 ## Extract @acronym{FIR} data from system data structure; see @command{fir2sys} for |
3430
|
24 ## parameter descriptions. |
|
25 ## @end deftypefn |
5053
|
26 ## |
3430
|
27 ## @seealso{fir2sys} |
|
28 |
|
29 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
30 ## Created: July 1996 |
|
31 |
|
32 function [c, tsam, inname, outname] = sys2fir (sys) |
|
33 |
|
34 ## let sys2tf do most of the work |
|
35 |
4462
|
36 [num, den, tsam, inname, outname] = sys2tf (sys); |
3430
|
37 |
|
38 alph = den(1); # scale to get monic denominator |
4462
|
39 den /= alph; |
|
40 num /= alph; |
|
41 l = length (den); |
|
42 m = length (num); |
|
43 if (norm (den(2:l))) |
|
44 sysout (sys, "tf"); |
|
45 error ("denominator has poles away from origin"); |
|
46 elseif (! is_digital (sys)) |
|
47 error ("system must be discrete-time to be FIR"); |
|
48 elseif (m != l) |
|
49 warning ("sys2fir: deg(num) - deg(den) = %d; coefficients must be shifted", |
|
50 m-l); |
3430
|
51 endif |
|
52 c = num; |
4462
|
53 |
3430
|
54 endfunction |
|
55 |