]> Creatis software - CreaPhase.git/blob - octave_packages/control-2.3.52/@lti/dssdata.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / control-2.3.52 / @lti / dssdata.m
1 ## Copyright (C) 2010, 2011   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{a}, @var{b}, @var{c}, @var{d}, @var{e}, @var{tsam}] =} dssdata (@var{sys})
20 ## @deftypefnx {Function File} {[@var{a}, @var{b}, @var{c}, @var{d}, @var{e}, @var{tsam}] =} dssdata (@var{sys}, @var{[]})
21 ## Access descriptor state-space model data.
22 ## Argument @var{sys} is not limited to descriptor state-space models.
23 ## If @var{sys} is not a descriptor state-space model, it is converted automatically.
24 ##
25 ## @strong{Inputs}
26 ## @table @var
27 ## @item sys
28 ## Any type of LTI model.
29 ## @item []
30 ## In case @var{sys} is not a dss model (descriptor matrix @var{e} empty),
31 ## @code{dssdata (sys, [])} returns the empty element @code{e = []} whereas
32 ## @code{dssdata (sys)} returns the identity matrix @code{e = eye (size (a))}.
33 ## @end table
34 ##
35 ## @strong{Outputs}
36 ## @table @var
37 ## @item a
38 ## State transition matrix (n-by-n).
39 ## @item b
40 ## Input matrix (n-by-m).
41 ## @item c
42 ## Measurement matrix (p-by-n).
43 ## @item d
44 ## Feedthrough matrix (p-by-m).
45 ## @item e
46 ## Descriptor matrix (n-by-n).
47 ## @item tsam
48 ## Sampling time in seconds.  If @var{sys} is a continuous-time model,
49 ## a zero is returned.
50 ## @end table
51 ## @end deftypefn
52
53 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
54 ## Created: September 2010
55 ## Version: 0.2
56
57 function [a, b, c, d, e, tsam, scaled] = dssdata (sys, flg = 0)
58
59   ## NOTE: In case sys is not a dss model (matrice e empty),
60   ##       dssdata (sys, []) returns e = [] whereas
61   ##       dssdata (sys) returns e = eye (size (a))
62
63   if (nargin > 2)
64     print_usage ();
65   endif
66
67   if (! isa (sys, "ss"))
68     sys = ss (sys);
69   endif
70
71   [a, b, c, d, e, ~, scaled] = __sys_data__ (sys);
72
73   if (isempty (e) && ! isempty (flg))
74     e = eye (size (a));  # return eye for ss models
75   endif
76
77   tsam = sys.tsam;
78
79 endfunction