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 |
|
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} {[@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 |
|
39 ## computed from the eigenvalues of the A-Matrix. |
|
40 ## @end table |
|
41 ## @strong{Outputs} |
|
42 ## @var{y}, @var{t}: impulse response |
|
43 ## @end deftypefn |
3438
|
44 ## @seealso{step and __stepimp__} |
3431
|
45 |
|
46 ## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de> |
|
47 ## Created: October 2, 1997 |
|
48 ## based on lsim.m of Scottedward Hodel |
|
49 ## modified by |
|
50 |
|
51 function [y, t] = impulse (sys, inp, tstop, n) |
|
52 |
3438
|
53 if ((nargin < 1) || (nargin > 4)) |
|
54 usage ("[y, u] = impulse (sys, inp, tstop, n)"); |
3431
|
55 endif |
|
56 |
3438
|
57 if (nargout > 2) |
|
58 usage ("[y, u] = impulse (sys, inp, tstop, n)"); |
3431
|
59 endif |
|
60 |
4030
|
61 if (! isstruct (sys)) |
3438
|
62 error ("impulse: sys must be a system data structure."); |
3431
|
63 endif |
|
64 |
|
65 if (nargout == 0) |
|
66 switch (nargin) |
|
67 case (1) |
3438
|
68 __stepimp__ (2, sys); |
3431
|
69 case (2) |
3438
|
70 __stepimp__ (2, sys, inp); |
3431
|
71 case (3) |
3438
|
72 __stepimp__ (2, sys, inp, tstop); |
3431
|
73 case (4) |
3438
|
74 __stepimp__ (2, sys, inp, tstop, n); |
3431
|
75 endswitch |
|
76 else |
|
77 switch (nargin) |
|
78 case (1) |
3438
|
79 [y, t] = __stepimp__ (2, sys); |
3431
|
80 case (2) |
3438
|
81 [y, t] = __stepimp__ (2, sys, inp); |
3431
|
82 case (3) |
3438
|
83 [y, t] = __stepimp__ (2, sys, inp, tstop); |
3431
|
84 case (4) |
3438
|
85 [y, t] = __stepimp__ (2, sys, inp, tstop, n); |
3431
|
86 endswitch |
|
87 endif |
|
88 |
|
89 endfunction |