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 |
|
6 ## under the terms of the GNU General Public License as published by the |
|
7 ## Free Software Foundation; either version 2, or (at your option) any |
|
8 ## later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 ## for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
5307
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301 USA. |
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 |
|
81 if(nargin != 1) |
6046
|
82 print_usage (); |
3430
|
83 endif |
|
84 |
|
85 if (nargout > 11) |
|
86 warning(["sys2ss: ",num2str(nargout)," out arguments exceeds max=11"]) |
6046
|
87 print_usage (); |
3430
|
88 endif |
|
89 |
4030
|
90 if( ! isstruct(sys) ) |
3430
|
91 error("input argument must be a system data structure"); |
|
92 endif |
|
93 |
|
94 sys = sysupdate(sys,"ss"); # make sure state space data is there |
|
95 [n,nz,m,p] = sysdimensions(sys); |
|
96 [stname,inname,outname,yd] = sysgetsignals(sys); |
|
97 tsam = sysgettsam(sys); |
|
98 |
|
99 cont = sum(yd == 0) + n; |
|
100 dig = sum(yd != 0) + nz + tsam; |
|
101 if(cont*dig) |
|
102 warning("sys2ss: input system is mixed continuous/discrete"); |
|
103 endif |
|
104 |
|
105 a = sys.a; |
|
106 b = sys.b; |
|
107 c = sys.c; |
|
108 d = sys.d; |
|
109 |
|
110 endfunction |
|
111 |