3430
|
1 ## Copyright (C) 1996, 1998 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 |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
|
18 |
|
19 ## -*- texinfo -*- |
3500
|
20 ## @deftypefn {Function File} {} fir2sys (@var{num}, @var{tsam}, @var{inname}, @var{outname}) |
3430
|
21 ## construct a system data structure from FIR description |
|
22 ## |
|
23 ## @strong{Inputs:} |
|
24 ## @table @var |
|
25 ## @item num |
|
26 ## vector of coefficients @math{[c_0 c_1 ... c_n]} |
|
27 ## of the SISO FIR transfer function |
|
28 ## @ifinfo |
|
29 ## |
|
30 ## C(z) = c0 + c1*z^@{-1@} + c2*z^@{-2@} + ... + znz^@{-n@} |
|
31 ## |
|
32 ## @end ifinfo |
|
33 ## @iftex |
|
34 ## @tex |
|
35 ## $$C(z) = c0 + c1*z^{-1} + c2*z^{-2} + ... + znz^{-n}$$ |
|
36 ## @end tex |
|
37 ## @end iftex |
|
38 ## |
|
39 ## @item tsam |
|
40 ## sampling time (default: 1) |
|
41 ## |
|
42 ## @item inname |
|
43 ## name of input signal; may be a string or a list with a single entry. |
|
44 ## |
|
45 ## @item outname |
|
46 ## name of output signal; may be a string or a list with a single entry. |
|
47 ## @end table |
|
48 ## |
|
49 ## @strong{Outputs} |
|
50 ## @var{sys} (system data structure) |
|
51 ## |
|
52 ## @strong{Example} |
|
53 ## @example |
|
54 ## octave:1> sys = fir2sys([1 -1 2 4],0.342,"A/D input","filter output"); |
|
55 ## octave:2> sysout(sys) |
|
56 ## Input(s) |
|
57 ## 1: A/D input |
|
58 ## |
|
59 ## Output(s): |
|
60 ## 1: filter output (discrete) |
|
61 ## |
|
62 ## Sampling interval: 0.342 |
|
63 ## transfer function form: |
|
64 ## 1*z^3 - 1*z^2 + 2*z^1 + 4 |
|
65 ## ------------------------- |
|
66 ## 1*z^3 + 0*z^2 + 0*z^1 + 0 |
|
67 ## @end example |
|
68 ## @end deftypefn |
|
69 |
|
70 ## Author: R. Bruce Tenison <btenison@eng.auburn.edu> |
|
71 ## Created: July 29, 1994 |
|
72 ## Name changed to TF2SYS July 1995 |
|
73 ## updated for new system data structure format July 1996 |
|
74 ## adapted from tf2sys july 1996 |
|
75 |
|
76 function sys = fir2sys (num, tsam, inname, outname) |
|
77 |
|
78 ## Test for the correct number of input arguments |
|
79 if (nargin < 1 | nargin > 4) |
|
80 usage ("sys = fir2sys(num [, tsam, inname, outname])"); |
|
81 endif |
|
82 |
|
83 ## let tf2sys do the argument checking |
|
84 den = [1,zeros(1,length(num)-1)]; |
|
85 |
|
86 ## check sampling interval (if any) |
|
87 if (nargin <= 1) |
|
88 tsam = 1; # default |
|
89 elseif (isempty(tsam)) |
|
90 tsam = 1; |
|
91 endif |
|
92 |
|
93 ## Set name of input |
|
94 if (nargin < 3) |
3438
|
95 inname = __sysdefioname__ (1, "u"); |
3430
|
96 endif |
|
97 |
|
98 ## Set name of output |
|
99 if (nargin < 4) |
3438
|
100 outname = __sysdefioname__ (1, "y"); |
3430
|
101 endif |
|
102 |
|
103 sys = tf2sys (num, den, tsam, inname, outname); |
|
104 |
|
105 endfunction |