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