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 |
|
17 ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. |
|
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) |
|
30 ## @item Adc |
|
31 ## @itemx Cdc |
|
32 ## connections from continuous states to discrete states and discrete |
|
33 ## outputs, respectively. |
|
34 ## @end table |
|
35 ## @end deftypefn |
|
36 |
|
37 function [dsys, Adc, Cdc] = sysdisc (sys) |
|
38 |
|
39 save_empty = empty_list_elements_ok; |
|
40 empty_list_elements_ok = 1; |
|
41 |
|
42 if (nargin != 1) |
|
43 usage("[dsys,Adc,Cdc] = sysdisc(sys)"); |
|
44 elseif (!is_struct(sys)) |
|
45 error("sys must be in system data structure form"); |
|
46 endif |
|
47 |
3438
|
48 sys = sysupdate (sys, "ss"); |
|
49 [n_tot, st_c, st_d, y_c, y_d] = __syscont_disc__ (sys); # get ranges |
3430
|
50 |
|
51 ## assume there's nothing there; build partitions as appropriate |
|
52 Add = Adc = Bdd = Cdd = Cdc = Ddd = []; |
|
53 |
|
54 if(isempty(st_d) & isempty(y_d)) |
|
55 error("sysdisc: expecting discrete states and/or continous outputs"); |
|
56 elseif (isempty(st_d)) |
|
57 warning("sysdisc: no discrete states"); |
|
58 elseif(isempty(y_d)) |
|
59 warning("sysdisc: no discrete outputs"); |
|
60 endif |
|
61 |
|
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)) |
|
68 Adc = aa( st_d , st_c); |
|
69 endif |
|
70 if(!isempty(y_d)) |
|
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)) |
|
80 Cdc = cc(y_d , st_c); |
|
81 endif |
|
82 else |
|
83 outname=[]; |
|
84 endif |
|
85 inname = sysgetsignals(sys,"in"); |
|
86 outlist = 1:rows(outname); |
|
87 |
|
88 if(!isempty(outname)) |
|
89 tsam = sysgettsam(sys); |
|
90 [nc,nz] = sysdimensions(sys); |
|
91 dsys = ss2sys(Add,Bdd,Cdd,Ddd,tsam,0,nz,stname,inname,outname,outlist); |
|
92 else |
|
93 dsys=[]; |
|
94 endif |
|
95 |
|
96 empty_list_elements_ok = save_empty; |
|
97 |
|
98 endfunction |