3430
|
1 ## Copyright (C) 1996 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 -*- |
3502
|
20 ## @deftypefn {Function File} {[@var{dsys}, @var{adc}, @var{cdc}] =} sysdisc (@var{sys}) |
3430
|
21 ## |
5016
|
22 ## @strong{Input} |
|
23 ## @table @var |
|
24 ## @item sys |
|
25 ## System data structure. |
|
26 ## @end table |
3430
|
27 ## |
|
28 ## @strong{Outputs} |
|
29 ## @table @var |
|
30 ## @item dsys |
5016
|
31 ## Purely discrete portion of sys (returned empty if there is |
|
32 ## no purely discrete path from inputs to outputs). |
3502
|
33 ## @item adc |
|
34 ## @itemx cdc |
7001
|
35 ## Connections from continuous states to discrete states and discrete |
3430
|
36 ## outputs, respectively. |
|
37 ## @end table |
|
38 ## @end deftypefn |
|
39 |
|
40 function [dsys, Adc, Cdc] = sysdisc (sys) |
|
41 |
5568
|
42 if (nargin != 1) |
6046
|
43 print_usage (); |
5568
|
44 elseif (!isstruct(sys)) |
|
45 error("sys must be in system data structure form"); |
|
46 endif |
3430
|
47 |
5568
|
48 sys = sysupdate (sys, "ss"); |
|
49 [n_tot, st_c, st_d, y_c, y_d] = __syscont_disc__ (sys); # get ranges |
3430
|
50 |
5568
|
51 ## assume there's nothing there; build partitions as appropriate |
|
52 Add = Adc = Bdd = Cdd = Cdc = Ddd = []; |
3430
|
53 |
5568
|
54 if(isempty(st_d) & isempty(y_d)) |
7001
|
55 error("sysdisc: expecting discrete states and/or continuous outputs"); |
5568
|
56 elseif (isempty(st_d)) |
|
57 warning("sysdisc: no discrete states"); |
|
58 elseif(isempty(y_d)) |
|
59 warning("sysdisc: no discrete outputs"); |
|
60 endif |
3430
|
61 |
5568
|
62 [aa,bb,cc,dd] = sys2ss(sys); |
|
63 if(!isempty(st_d) ) |
|
64 Add = aa( st_d , st_d); |
|
65 stname = sysgetsignals(sys,"st",st_d); |
|
66 Bdd = bb( st_d , :); |
|
67 if(!isempty(st_c)) |
4460
|
68 Adc = aa( st_d , st_c); |
3430
|
69 endif |
|
70 if(!isempty(y_d)) |
5568
|
71 Cdd = cc(y_d , st_d); |
|
72 endif |
|
73 else |
|
74 stname = []; |
|
75 endif |
|
76 if(!isempty(y_d)) |
|
77 Ddd = dd(y_d , :); |
|
78 outname = sysgetsignals(sys,"out",y_d); |
|
79 if(!isempty(st_c)) |
4460
|
80 Cdc = cc(y_d , st_c); |
3430
|
81 endif |
5568
|
82 else |
|
83 outname=[]; |
|
84 endif |
|
85 inname = sysgetsignals(sys,"in"); |
|
86 outlist = 1:rows(outname); |
3430
|
87 |
5568
|
88 if(!isempty(outname)) |
|
89 tsam = sysgettsam(sys); |
|
90 [nc,nz] = sysdimensions(sys); |
|
91 dsys = ss(Add,Bdd,Cdd,Ddd,tsam,0,nz,stname,inname,outname,outlist); |
|
92 else |
|
93 dsys=[]; |
|
94 endif |
3430
|
95 |
|
96 endfunction |