7017
|
1 ## Copyright (C) 1996, 1998, 2000, 2002, 2004, 2005, 2006, 2007 |
|
2 ## Auburn University. All rights reserved. |
3430
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
7016
|
7 ## under the terms of the GNU General Public License as published by |
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
3430
|
10 ## |
7016
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
3430
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
3430
|
19 |
|
20 ## -*- texinfo -*- |
3500
|
21 ## @deftypefn {Function File} {[@var{a}, @var{b}, @var{c}, @var{d}, @var{tsam}, @var{n}, @var{nz}, @var{stname}, @var{inname}, @var{outname}, @var{yd}] =} sys2ss (@var{sys}) |
3430
|
22 ## Extract state space representation from system data structure. |
|
23 ## |
5016
|
24 ## @strong{Input} |
|
25 ## @table @var |
|
26 ## @item sys |
|
27 ## System data structure. |
|
28 ## @end table |
3430
|
29 ## |
|
30 ## @strong{Outputs} |
|
31 ## @table @var |
|
32 ## @item a |
|
33 ## @itemx b |
|
34 ## @itemx c |
|
35 ## @itemx d |
5016
|
36 ## State space matrices for @var{sys}. |
3430
|
37 ## |
|
38 ## @item tsam |
5016
|
39 ## Sampling time of @var{sys} (0 if continuous). |
3430
|
40 ## |
|
41 ## @item n |
|
42 ## @itemx nz |
5016
|
43 ## Number of continuous, discrete states (discrete states come |
|
44 ## last in state vector @var{x}). |
3430
|
45 ## |
|
46 ## @item stname |
|
47 ## @itemx inname |
|
48 ## @itemx outname |
5016
|
49 ## Signal names (lists of strings); names of states, |
|
50 ## inputs, and outputs, respectively. |
3430
|
51 ## |
|
52 ## @item yd |
5016
|
53 ## Binary vector; @var{yd}(@var{ii}) is 1 if output @var{y}(@var{ii}) |
|
54 ## is discrete (sampled); otherwise @var{yd}(@var{ii}) is 0. |
3430
|
55 ## |
|
56 ## @end table |
|
57 ## A warning massage is printed if the system is a mixed |
5016
|
58 ## continuous and discrete system. |
3430
|
59 ## |
|
60 ## @strong{Example} |
|
61 ## @example |
|
62 ## octave:1> sys=tf2sys([1 2],[3 4 5]); |
|
63 ## octave:2> [a,b,c,d] = sys2ss(sys) |
|
64 ## a = |
|
65 ## 0.00000 1.00000 |
|
66 ## -1.66667 -1.33333 |
|
67 ## b = |
|
68 ## 0 |
|
69 ## 1 |
|
70 ## c = 0.66667 0.33333 |
|
71 ## d = 0 |
|
72 ## @end example |
|
73 ## @end deftypefn |
|
74 |
|
75 ## Author: David Clem |
|
76 ## Created: August 19, 1994 |
|
77 ## Updates by John Ingram July 14, 1996 |
|
78 |
|
79 function [a, b, c, d, tsam, n, nz, stname, inname, outname, yd] = sys2ss (sys) |
|
80 |
7133
|
81 if (nargin != 1) |
6046
|
82 print_usage (); |
3430
|
83 endif |
|
84 |
7136
|
85 if (! isstruct (sys)) |
|
86 error ("input argument must be a system data structure"); |
3430
|
87 endif |
|
88 |
7136
|
89 sys = sysupdate (sys, "ss"); # make sure state space data is there |
|
90 [n, nz, m, p] = sysdimensions (sys); |
|
91 [stname, inname, outname, yd] = sysgetsignals (sys); |
|
92 tsam = sysgettsam (sys); |
3430
|
93 |
7136
|
94 cont = sum (yd == 0) + n; |
|
95 dig = sum (yd != 0) + nz + tsam; |
|
96 if (cont*dig) |
|
97 warning ("sys2ss: input system is mixed continuous/discrete"); |
3430
|
98 endif |
|
99 |
|
100 a = sys.a; |
|
101 b = sys.b; |
|
102 c = sys.c; |
|
103 d = sys.d; |
|
104 |
|
105 endfunction |
|
106 |