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 |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
3431
|
19 |
|
20 ## -*- texinfo -*- |
3500
|
21 ## @deftypefn {Function File} {[@var{y}, @var{t}] =} step (@var{sys}, @var{inp}, @var{tstop}, @var{n}) |
3431
|
22 ## Step response for a linear system. |
|
23 ## The system can be discrete or multivariable (or both). |
|
24 ## If no output arguments are specified, @code{step} |
|
25 ## produces a plot or the step response data for system @var{sys}. |
|
26 ## |
|
27 ## @strong{Inputs} |
|
28 ## @table @var |
|
29 ## @item sys |
|
30 ## System data structure. |
|
31 ## @item inp |
|
32 ## Index of input being excited |
|
33 ## @item tstop |
|
34 ## The argument @var{tstop} (scalar value) denotes the time when the |
|
35 ## simulation should end. |
|
36 ## @item n |
|
37 ## the number of data values. |
|
38 ## |
|
39 ## Both parameters @var{tstop} and @var{n} can be omitted and will be |
5016
|
40 ## computed from the eigenvalues of the A Matrix. |
3431
|
41 ## @end table |
|
42 ## @strong{Outputs} |
5016
|
43 ## @table @var |
|
44 ## @item y |
|
45 ## Values of the step response. |
|
46 ## @item t |
|
47 ## Times of the step response. |
|
48 ## @end table |
3431
|
49 ## |
5016
|
50 ## When invoked with the output parameter @var{y} the plot is not displayed. |
6944
|
51 ## @seealso{impulse} |
3431
|
52 ## @end deftypefn |
|
53 |
|
54 ## Author: Kai P. Mueller <mueller@ifr.ing.tu-bs.de> |
|
55 ## Created: September 30, 1997 |
|
56 ## based on lsim.m of Scottedward Hodel |
|
57 |
|
58 function [y, t] = step (sys, inp, tstop, n) |
|
59 |
3438
|
60 if ((nargin < 1) || (nargin > 4)) |
6046
|
61 print_usage (); |
3431
|
62 endif |
|
63 |
3438
|
64 if (nargout > 2) |
6046
|
65 print_usage (); |
3431
|
66 endif |
|
67 |
4030
|
68 if (! isstruct (sys)) |
3438
|
69 error ("step: sys must be a system data structure."); |
3431
|
70 endif |
|
71 |
|
72 if (nargout == 0) |
|
73 switch (nargin) |
|
74 case (1) |
3438
|
75 __stepimp__ (1, sys); |
3431
|
76 case (2) |
3438
|
77 __stepimp__ (1, sys, inp); |
3431
|
78 case (3) |
3438
|
79 __stepimp__ (1, sys, inp, tstop); |
3431
|
80 case (4) |
3438
|
81 __stepimp__ (1, sys, inp, tstop, n); |
3431
|
82 endswitch |
|
83 else |
|
84 switch (nargin) |
|
85 case (1) |
3438
|
86 [y, t] = __stepimp__ (1, sys); |
3431
|
87 case (2) |
3438
|
88 [y, t] = __stepimp__ (1, sys, inp); |
3431
|
89 case (3) |
3438
|
90 [y, t] = __stepimp__ (1, sys, inp, tstop); |
3431
|
91 case (4) |
3438
|
92 [y, t] = __stepimp__ (1, sys, inp, tstop, n); |
3431
|
93 endswitch |
|
94 endif |
|
95 |
|
96 endfunction |