3397
|
1 ## Copyright (C) 1996 Auburn University. All rights reserved. |
3381
|
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. |
3346
|
18 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File } { [@var{dsys}, @var{Adc}, @var{Cdc}] =} sysdisc (@var{sys}) |
|
21 ## |
|
22 ## @strong{Inputs} |
|
23 ## @var{sys} = system data structure |
|
24 ## |
|
25 ## @strong{Outputs} |
|
26 ## @table @var |
|
27 ## @item dsys |
|
28 ## purely discrete portion of sys (returned empty if there is |
|
29 ## no purely discrete path from inputs to outputs) |
3402
|
30 ## @item Adc |
|
31 ## @itemx Cdc |
3346
|
32 ## connections from continuous states to discrete states and discrete |
|
33 ## outputs, respectively. |
|
34 ## @end table |
|
35 ## |
|
36 ## @end deftypefn |
3213
|
37 |
3385
|
38 function [dsys, Adc, Cdc] = sysdisc (sys) |
3381
|
39 |
3213
|
40 save_empty = empty_list_elements_ok; |
3383
|
41 empty_list_elements_ok = 1; |
3213
|
42 |
|
43 if (nargin != 1) |
|
44 usage("[dsys,Adc,Cdc] = sysdisc(sys)"); |
|
45 elseif (!is_struct(sys)) |
|
46 error("sys must be in system data structure form"); |
|
47 endif |
|
48 |
|
49 sys = sysupdate(sys,"ss"); |
|
50 [n_tot,st_c,st_d,y_c,y_d] = syscont_disc(sys); # get ranges |
|
51 |
3381
|
52 ## assume there's nothing there; build partitions as appropriate |
3213
|
53 Add = Adc = Bdd = Cdd = Cdc = Ddd = []; |
|
54 |
|
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 |
|
62 |
3228
|
63 [aa,bb,cc,dd] = sys2ss(sys); |
3213
|
64 if(!isempty(st_d) ) |
3228
|
65 Add = aa( st_d , st_d); |
|
66 stname = sysgetsignals(sys,"st",st_d); |
|
67 Bdd = bb( st_d , :); |
3213
|
68 if(!isempty(st_c)) |
3228
|
69 Adc = aa( st_d , st_c); |
3213
|
70 endif |
|
71 if(!isempty(y_d)) |
3228
|
72 Cdd = cc(y_d , st_d); |
3213
|
73 endif |
|
74 else |
|
75 stname = []; |
|
76 endif |
|
77 if(!isempty(y_d)) |
3228
|
78 Ddd = dd(y_d , :); |
|
79 outname = sysgetsignals(sys,"out",y_d); |
3213
|
80 if(!isempty(st_c)) |
3228
|
81 Cdc = cc(y_d , st_c); |
3213
|
82 endif |
|
83 else |
|
84 outname=[]; |
|
85 endif |
3228
|
86 inname = sysgetsignals(sys,"in"); |
3213
|
87 outlist = 1:rows(outname); |
|
88 |
|
89 if(!isempty(outname)) |
3228
|
90 tsam = sysgettsam(sys); |
|
91 [nc,nz] = sysdimensions(sys); |
|
92 dsys = ss2sys(Add,Bdd,Cdd,Ddd,tsam,0,nz,stname,inname,outname,outlist); |
3213
|
93 else |
|
94 dsys=[]; |
|
95 endif |
3383
|
96 |
3213
|
97 empty_list_elements_ok = save_empty; |
|
98 |
|
99 endfunction |