7017
|
1 ## Copyright (C) 1996, 1998, 2000, 2002, 2004, 2005, 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 -*- |
4771
|
21 ## @deftypefn {Function File} {} ss (@var{a}, @var{b}, @var{c}, @var{d}, @var{tsam}, @var{n}, @var{nz}, @var{stname}, @var{inname}, @var{outname}, @var{outlist}) |
7001
|
22 ## Create system structure from state-space data. May be continuous, |
5016
|
23 ## discrete, or mixed (sampled data) |
3430
|
24 ## |
|
25 ## @strong{Inputs} |
|
26 ## @table @var |
|
27 ## @item a |
|
28 ## @itemx b |
|
29 ## @itemx c |
|
30 ## @itemx d |
|
31 ## usual state space matrices. |
|
32 ## |
|
33 ## default: @var{d} = zero matrix |
|
34 ## |
|
35 ## @item tsam |
|
36 ## sampling rate. Default: @math{tsam = 0} (continuous system) |
|
37 ## |
|
38 ## @item n |
|
39 ## @itemx nz |
|
40 ## number of continuous, discrete states in the system |
|
41 ## |
|
42 ## If @var{tsam} is 0, @math{n = @code{rows}(@var{a})}, @math{nz = 0}. |
|
43 ## |
|
44 ## If @var{tsam} is greater than zero, @math{n = 0}, |
|
45 ## @math{nz = @code{rows}(@var{a})} |
|
46 ## |
|
47 ## see below for system partitioning |
|
48 ## |
|
49 ## @item stname |
4844
|
50 ## cell array of strings of state signal names |
3430
|
51 ## |
|
52 ## default (@var{stname}=[] on input): @code{x_n} for continuous states, |
|
53 ## @code{xd_n} for discrete states |
|
54 ## |
|
55 ## @item inname |
4844
|
56 ## cell array of strings of input signal names |
3430
|
57 ## |
|
58 ## default (@var{inname} = [] on input): @code{u_n} |
|
59 ## |
|
60 ## @item outname |
4844
|
61 ## cell array of strings of input signal names |
3430
|
62 ## |
|
63 ## default (@var{outname} = [] on input): @code{y_n} |
|
64 ## |
|
65 ## @item outlist |
|
66 ## |
|
67 ## list of indices of outputs y that are sampled |
|
68 ## |
|
69 ## If @var{tsam} is 0, @math{outlist = []}. |
|
70 ## |
|
71 ## If @var{tsam} is greater than 0, @math{outlist = 1:@code{rows}(@var{c})}. |
|
72 ## @end table |
|
73 ## |
7001
|
74 ## Unlike states, discrete/continuous outputs may appear in any order. |
3430
|
75 ## |
4946
|
76 ## @code{sys2ss} returns a vector @var{yd} where |
3430
|
77 ## @var{yd}(@var{outlist}) = 1; all other entries of @var{yd} are 0. |
|
78 ## |
|
79 ## @strong{Outputs} |
|
80 ## @var{outsys} = system data structure |
|
81 ## |
|
82 ## @strong{System partitioning} |
|
83 ## |
|
84 ## Suppose for simplicity that outlist specified |
|
85 ## that the first several outputs were continuous and the remaining outputs |
|
86 ## were discrete. Then the system is partitioned as |
|
87 ## @example |
|
88 ## @group |
|
89 ## x = [ xc ] (n x 1) |
|
90 ## [ xd ] (nz x 1 discrete states) |
|
91 ## a = [ acc acd ] b = [ bc ] |
|
92 ## [ adc add ] [ bd ] |
|
93 ## c = [ ccc ccd ] d = [ dc ] |
|
94 ## [ cdc cdd ] [ dd ] |
|
95 ## |
|
96 ## (cdc = c(outlist,1:n), etc.) |
|
97 ## @end group |
|
98 ## @end example |
|
99 ## with dynamic equations: |
|
100 ## @ifinfo |
3500
|
101 ## @math{d/dt xc(t) = acc*xc(t) + acd*xd(k*tsam) + bc*u(t)} |
3430
|
102 ## |
3500
|
103 ## @math{xd((k+1)*tsam) = adc*xc(k*tsam) + add*xd(k*tsam) + bd*u(k*tsam)} |
3430
|
104 ## |
3500
|
105 ## @math{yc(t) = ccc*xc(t) + ccd*xd(k*tsam) + dc*u(t)} |
3430
|
106 ## |
3500
|
107 ## @math{yd(k*tsam) = cdc*xc(k*tsam) + cdd*xd(k*tsam) + dd*u(k*tsam)} |
3430
|
108 ## @end ifinfo |
|
109 ## @iftex |
|
110 ## @tex |
|
111 ## $$\eqalign{ |
|
112 ## {d \over dt} x_c(t) |
|
113 ## & = a_{cc} x_c(t) + a_{cd} x_d(k*t_{sam}) + bc*u(t) \cr |
|
114 ## x_d((k+1)*t_{sam}) |
|
115 ## & = a_{dc} x_c(k t_{sam}) + a_{dd} x_d(k t_{sam}) + b_d u(k t_{sam}) \cr |
|
116 ## y_c(t) |
|
117 ## & = c_{cc} x_c(t) + c_{cd} x_d(k t_{sam}) + d_c u(t) \cr |
|
118 ## y_d(k t_{sam}) |
|
119 ## & = c_{dc} x_c(k t_{sam}) + c_{dd} x_d(k t_{sam}) + d_d u(k t_{sam}) |
|
120 ## }$$ |
|
121 ## @end tex |
|
122 ## @end iftex |
|
123 ## |
|
124 ## @strong{Signal partitions} |
|
125 ## @example |
|
126 ## @group |
|
127 ## | continuous | discrete | |
|
128 ## ---------------------------------------------------- |
|
129 ## states | stname(1:n,:) | stname((n+1):(n+nz),:) | |
|
130 ## ---------------------------------------------------- |
|
131 ## outputs | outname(cout,:) | outname(outlist,:) | |
|
132 ## ---------------------------------------------------- |
|
133 ## @end group |
|
134 ## @end example |
|
135 ## where @math{cout} is the list of in 1:@code{rows}(@var{p}) |
|
136 ## that are not contained in outlist. (Discrete/continuous outputs |
|
137 ## may be entered in any order desired by the user.) |
|
138 ## |
|
139 ## @strong{Example} |
|
140 ## @example |
|
141 ## octave:1> a = [1 2 3; 4 5 6; 7 8 10]; |
|
142 ## octave:2> b = [0 0 ; 0 1 ; 1 0]; |
4855
|
143 ## octave:3> c = eye (3); |
|
144 ## octave:4> sys = ss (a, b, c, [], 0, 3, 0, @{"volts", "amps", "joules"@}); |
3430
|
145 ## octave:5> sysout(sys); |
|
146 ## Input(s) |
|
147 ## 1: u_1 |
|
148 ## 2: u_2 |
|
149 ## |
|
150 ## Output(s): |
|
151 ## 1: y_1 |
|
152 ## 2: y_2 |
|
153 ## 3: y_3 |
|
154 ## |
|
155 ## state-space form: |
|
156 ## 3 continuous states, 0 discrete states |
|
157 ## State(s): |
|
158 ## 1: volts |
|
159 ## 2: amps |
|
160 ## 3: joules |
|
161 ## |
|
162 ## A matrix: 3 x 3 |
|
163 ## 1 2 3 |
|
164 ## 4 5 6 |
|
165 ## 7 8 10 |
|
166 ## B matrix: 3 x 2 |
|
167 ## 0 0 |
|
168 ## 0 1 |
|
169 ## 1 0 |
|
170 ## C matrix: 3 x 3 |
|
171 ## 1 0 0 |
|
172 ## 0 1 0 |
|
173 ## 0 0 1 |
|
174 ## D matrix: 3 x 3 |
|
175 ## 0 0 |
|
176 ## 0 0 |
|
177 ## 0 0 |
|
178 ## @end example |
3502
|
179 ## Notice that the @math{D} matrix is constructed by default to the |
3430
|
180 ## correct dimensions. Default input and output signals names were assigned |
|
181 ## since none were given. |
|
182 ## @end deftypefn |
|
183 |
|
184 ## Author: John Ingram <ingraje@eng.auburn.edu> |
|
185 ## Created: July 20, 1996 |
|
186 |
4771
|
187 function retsys = ss2sys (varargin ) |
|
188 |
|
189 warning("ss2sys is deprecated. Use ss() instead."); |
|
190 retsys = ss(varargin{:}); |
3430
|
191 |
|
192 endfunction |