3431
|
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 |
7016
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
3431
|
9 ## |
7016
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
3431
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
3431
|
18 |
|
19 ## -*- texinfo -*- |
3500
|
20 ## @deftypefn {Function File} {[@var{y}, @var{t}] =} impulse (@var{sys}, @var{inp}, @var{tstop}, @var{n}) |
3431
|
21 ## Impulse response for a linear system. |
|
22 ## The system can be discrete or multivariable (or both). |
|
23 ## If no output arguments are specified, @code{impulse} |
|
24 ## produces a plot or the impulse response data for system @var{sys}. |
|
25 ## |
|
26 ## @strong{Inputs} |
|
27 ## @table @var |
|
28 ## @item sys |
|
29 ## System data structure. |
|
30 ## @item inp |
|
31 ## Index of input being excited |
|
32 ## @item tstop |
|
33 ## The argument @var{tstop} (scalar value) denotes the time when the |
|
34 ## simulation should end. |
|
35 ## @item n |
|
36 ## the number of data values. |
|
37 ## |
|
38 ## Both parameters @var{tstop} and @var{n} can be omitted and will be |
5016
|
39 ## computed from the eigenvalues of the A Matrix. |
3431
|
40 ## @end table |
|
41 ## @strong{Outputs} |
5016
|
42 ## @table @var |
|
43 ## @item y |
|
44 ## Values of the impulse response. |
|
45 ## @item t |
|
46 ## Times of the impulse response. |
|
47 ## @end table |
6944
|
48 ## @seealso{step} |
3431
|
49 ## @end deftypefn |
|
50 |
|
51 ## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de> |
|
52 ## Created: October 2, 1997 |
|
53 ## based on lsim.m of Scottedward Hodel |
|
54 ## modified by |
|
55 |
|
56 function [y, t] = impulse (sys, inp, tstop, n) |
|
57 |
3438
|
58 if ((nargin < 1) || (nargin > 4)) |
6046
|
59 print_usage (); |
3431
|
60 endif |
|
61 |
3438
|
62 if (nargout > 2) |
6046
|
63 print_usage (); |
3431
|
64 endif |
|
65 |
4030
|
66 if (! isstruct (sys)) |
3438
|
67 error ("impulse: sys must be a system data structure."); |
3431
|
68 endif |
|
69 |
|
70 if (nargout == 0) |
|
71 switch (nargin) |
|
72 case (1) |
3438
|
73 __stepimp__ (2, sys); |
3431
|
74 case (2) |
3438
|
75 __stepimp__ (2, sys, inp); |
3431
|
76 case (3) |
3438
|
77 __stepimp__ (2, sys, inp, tstop); |
3431
|
78 case (4) |
3438
|
79 __stepimp__ (2, sys, inp, tstop, n); |
3431
|
80 endswitch |
|
81 else |
|
82 switch (nargin) |
|
83 case (1) |
3438
|
84 [y, t] = __stepimp__ (2, sys); |
3431
|
85 case (2) |
3438
|
86 [y, t] = __stepimp__ (2, sys, inp); |
3431
|
87 case (3) |
3438
|
88 [y, t] = __stepimp__ (2, sys, inp, tstop); |
3431
|
89 case (4) |
3438
|
90 [y, t] = __stepimp__ (2, sys, inp, tstop, n); |
3431
|
91 endswitch |
|
92 endif |
|
93 |
|
94 endfunction |