]> Creatis software - CreaPhase.git/blob - octave_packages/control-2.3.52/dss.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / control-2.3.52 / dss.m
1 ## Copyright (C) 2010   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{sys} =} dss (@var{sys})
20 ## @deftypefnx {Function File} {@var{sys} =} dss (@var{d})
21 ## @deftypefnx {Function File} {@var{sys} =} dss (@var{a}, @var{b}, @var{c}, @var{d}, @var{e}, @dots{})
22 ## @deftypefnx {Function File} {@var{sys} =} dss (@var{a}, @var{b}, @var{c}, @var{d}, @var{e}, @var{tsam}, @dots{})
23 ## Create or convert to descriptor state-space model.
24 ##
25 ## @strong{Inputs}
26 ## @table @var
27 ## @item sys
28 ## LTI model to be converted to state-space.
29 ## @item a
30 ## State transition matrix (n-by-n).
31 ## @item b
32 ## Input matrix (n-by-m).
33 ## @item c
34 ## Measurement matrix (p-by-n).
35 ## @item d
36 ## Feedthrough matrix (p-by-m).
37 ## @item e
38 ## Descriptor matrix (n-by-n).
39 ## @item tsam
40 ## Sampling time in seconds.  If @var{tsam} is not specified, 
41 ## a continuous-time model is assumed.
42 ## @item @dots{}
43 ## Optional pairs of properties and values.
44 ## Type @command{set (dss)} for more information.
45 ## @end table
46 ##
47 ## @strong{Outputs}
48 ## @table @var
49 ## @item sys
50 ## Descriptor state-space model.
51 ## @end table
52 ##
53 ## @strong{Equations}
54 ## @example
55 ## @group
56 ##   .
57 ## E x = A x + B u
58 ##   y = C x + D u
59 ## @end group
60 ## @end example
61 ##
62 ## @seealso{ss, tf}
63 ## @end deftypefn
64
65 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
66 ## Created: September 2010
67 ## Version: 0.1
68
69 function sys = dss (varargin)
70
71   switch (nargin)
72     case {0, 1}  # static gain (dss (5)) or empty (useful for "set (dss)")
73       sys = ss (varargin{:});
74
75     case {2, 3, 4}
76       print_usage ();
77
78     otherwise    # general case
79       sys = ss (varargin{[1:4, 6:end]}, "e", varargin{5});
80   endswitch
81
82 endfunction
83
84 ## NOTE: The author prefers "dss (e, a, b, c, d)" since we write
85 ##         .
86 ##       E x = A x + B u,     y = C x + D u
87 ##
88 ##       but this would break compatibility to a widespread
89 ##       commercial implementation of the octave language.
90 ##       There's no way to tell e and d apart if n = m = p.