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 |
4460
|
43 save_warn_empty_list_elements = warn_empty_list_elements; |
|
44 unwind_protect |
|
45 warn_empty_list_elements = 0; |
3430
|
46 |
4460
|
47 if (nargin != 1) |
|
48 usage("[dsys,Adc,Cdc] = sysdisc(sys)"); |
|
49 elseif (!isstruct(sys)) |
|
50 error("sys must be in system data structure form"); |
|
51 endif |
3430
|
52 |
4460
|
53 sys = sysupdate (sys, "ss"); |
|
54 [n_tot, st_c, st_d, y_c, y_d] = __syscont_disc__ (sys); # get ranges |
3430
|
55 |
4460
|
56 ## assume there's nothing there; build partitions as appropriate |
|
57 Add = Adc = Bdd = Cdd = Cdc = Ddd = []; |
3430
|
58 |
4460
|
59 if(isempty(st_d) & isempty(y_d)) |
|
60 error("sysdisc: expecting discrete states and/or continous outputs"); |
|
61 elseif (isempty(st_d)) |
|
62 warning("sysdisc: no discrete states"); |
|
63 elseif(isempty(y_d)) |
|
64 warning("sysdisc: no discrete outputs"); |
|
65 endif |
3430
|
66 |
4460
|
67 [aa,bb,cc,dd] = sys2ss(sys); |
|
68 if(!isempty(st_d) ) |
|
69 Add = aa( st_d , st_d); |
|
70 stname = sysgetsignals(sys,"st",st_d); |
|
71 Bdd = bb( st_d , :); |
|
72 if(!isempty(st_c)) |
|
73 Adc = aa( st_d , st_c); |
|
74 endif |
|
75 if(!isempty(y_d)) |
|
76 Cdd = cc(y_d , st_d); |
|
77 endif |
|
78 else |
|
79 stname = []; |
3430
|
80 endif |
|
81 if(!isempty(y_d)) |
4460
|
82 Ddd = dd(y_d , :); |
|
83 outname = sysgetsignals(sys,"out",y_d); |
|
84 if(!isempty(st_c)) |
|
85 Cdc = cc(y_d , st_c); |
|
86 endif |
|
87 else |
|
88 outname=[]; |
3430
|
89 endif |
4460
|
90 inname = sysgetsignals(sys,"in"); |
|
91 outlist = 1:rows(outname); |
3430
|
92 |
4460
|
93 if(!isempty(outname)) |
|
94 tsam = sysgettsam(sys); |
|
95 [nc,nz] = sysdimensions(sys); |
4771
|
96 dsys = ss(Add,Bdd,Cdd,Ddd,tsam,0,nz,stname,inname,outname,outlist); |
4460
|
97 else |
|
98 dsys=[]; |
|
99 endif |
3430
|
100 |
4460
|
101 unwind_protect_cleanup |
|
102 warn_empty_list_elements = save_warn_empty_list_elements; |
|
103 end_unwind_protect |
3430
|
104 |
|
105 endfunction |