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