3381
|
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. |
3346
|
18 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File } { @var{sys} =} fir2sys ( @var{num}@{, @var{tsam}, @var{inname}, @var{outname} @} ) |
|
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 |
3213
|
69 |
|
70 function sys = fir2sys (num,tsam,inname,outname) |
3381
|
71 |
|
72 ## Written by R. Bruce Tenison July 29, 1994 |
|
73 ## Name changed to TF2SYS July 1995 |
|
74 ## updated for new system data structure format July 1996 |
|
75 ## adapted from tf2sys july 1996 |
3213
|
76 |
3381
|
77 ## Test for the correct number of input arguments |
3228
|
78 if (nargin < 1 | nargin > 4) |
3213
|
79 usage('sys=fir2sys(num[,tsam,inname,outname])'); |
|
80 endif |
|
81 |
3381
|
82 ## let tf2sys do the argument checking |
3213
|
83 den = [1,zeros(1,length(num)-1)]; |
|
84 |
3381
|
85 ## check sampling interval (if any) |
3228
|
86 if(nargin <= 1) tsam = 1; # default |
|
87 elseif (isempty(tsam)) tsam = 1; endif |
3213
|
88 |
3381
|
89 ## Set name of input |
3228
|
90 if(nargin < 3) inname = sysdefioname(1,"u"); endif |
3213
|
91 |
3381
|
92 ## Set name of output |
3228
|
93 if(nargin < 4) outname = sysdefioname(1,"y"); endif |
|
94 |
|
95 sys = tf2sys(num,den,tsam,inname,outname); |
3213
|
96 |
|
97 endfunction |