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