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