]> Creatis software - CreaPhase.git/blob - octave_packages/control-2.3.52/impulse.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / control-2.3.52 / impulse.m
1 ## Copyright (C) 2009   Lukas F. Reichlin
2 ##
3 ## This file is part of LTI Syncope.
4 ##
5 ## LTI Syncope is free software: you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, either version 3 of the License, or
8 ## (at your option) any later version.
9 ##
10 ## LTI Syncope is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ## GNU General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with LTI Syncope.  If not, see <http://www.gnu.org/licenses/>.
17
18 ## -*- texinfo -*-
19 ## @deftypefn{Function File} {[@var{y}, @var{t}, @var{x}] =} impulse (@var{sys})
20 ## @deftypefnx{Function File} {[@var{y}, @var{t}, @var{x}] =} impulse (@var{sys}, @var{t})
21 ## @deftypefnx{Function File} {[@var{y}, @var{t}, @var{x}] =} impulse (@var{sys}, @var{tfinal})
22 ## @deftypefnx{Function File} {[@var{y}, @var{t}, @var{x}] =} impulse (@var{sys}, @var{tfinal}, @var{dt})
23 ## Impulse response of LTI system.
24 ## If no output arguments are given, the response is printed on the screen.
25 ##
26 ## @strong{Inputs}
27 ## @table @var
28 ## @item sys
29 ## LTI model.
30 ## @item t
31 ## Time vector.  Should be evenly spaced.  If not specified, it is calculated by
32 ## the poles of the system to reflect adequately the response transients.
33 ## @item tfinal
34 ## Optional simulation horizon.  If not specified, it is calculated by
35 ## the poles of the system to reflect adequately the response transients.
36 ## @item dt
37 ## Optional sampling time.  Be sure to choose it small enough to capture transient
38 ## phenomena.  If not specified, it is calculated by the poles of the system.
39 ## @end table
40 ##
41 ## @strong{Outputs}
42 ## @table @var
43 ## @item y
44 ## Output response array.  Has as many rows as time samples (length of t)
45 ## and as many columns as outputs.
46 ## @item t
47 ## Time row vector.
48 ## @item x
49 ## State trajectories array.  Has @code{length (t)} rows and as many columns as states.
50 ## @end table
51 ##
52 ## @seealso{initial, lsim, step}
53 ## @end deftypefn
54
55 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
56 ## Created: October 2009
57 ## Version: 0.1
58
59 function [y_r, t_r, x_r] = impulse (sys, tfinal = [], dt = [])
60
61   ## TODO: multiplot feature:   impulse (sys1, "b", sys2, "r", ...)
62
63   if (nargin == 0 || nargin > 3)
64     print_usage ();
65   endif
66
67   [y, t, x] = __time_response__ (sys, "impulse", ! nargout, tfinal, dt, [], inputname (1));
68
69   if (nargout)
70     y_r = y;
71     t_r = t;
72     x_r = x;
73   endif
74
75 endfunction