Mercurial > hg > octave-nkf
comparison scripts/control/system/sysdisc.m @ 5568:e9cde940b271
[project @ 2005-12-08 02:28:22 by jwe]
author | jwe |
---|---|
date | Thu, 08 Dec 2005 02:28:22 +0000 |
parents | 4c8a2e4e0717 |
children | 34f96dd5441b |
comparison
equal
deleted
inserted
replaced
5567:80e629357483 | 5568:e9cde940b271 |
---|---|
38 ## @end table | 38 ## @end table |
39 ## @end deftypefn | 39 ## @end deftypefn |
40 | 40 |
41 function [dsys, Adc, Cdc] = sysdisc (sys) | 41 function [dsys, Adc, Cdc] = sysdisc (sys) |
42 | 42 |
43 save_warn_empty_list_elements = warn_empty_list_elements; | 43 if (nargin != 1) |
44 unwind_protect | 44 usage("[dsys,Adc,Cdc] = sysdisc(sys)"); |
45 warn_empty_list_elements = 0; | 45 elseif (!isstruct(sys)) |
46 error("sys must be in system data structure form"); | |
47 endif | |
46 | 48 |
47 if (nargin != 1) | 49 sys = sysupdate (sys, "ss"); |
48 usage("[dsys,Adc,Cdc] = sysdisc(sys)"); | 50 [n_tot, st_c, st_d, y_c, y_d] = __syscont_disc__ (sys); # get ranges |
49 elseif (!isstruct(sys)) | |
50 error("sys must be in system data structure form"); | |
51 endif | |
52 | 51 |
53 sys = sysupdate (sys, "ss"); | 52 ## assume there's nothing there; build partitions as appropriate |
54 [n_tot, st_c, st_d, y_c, y_d] = __syscont_disc__ (sys); # get ranges | 53 Add = Adc = Bdd = Cdd = Cdc = Ddd = []; |
55 | 54 |
56 ## assume there's nothing there; build partitions as appropriate | 55 if(isempty(st_d) & isempty(y_d)) |
57 Add = Adc = Bdd = Cdd = Cdc = Ddd = []; | 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 | |
58 | 62 |
59 if(isempty(st_d) & isempty(y_d)) | 63 [aa,bb,cc,dd] = sys2ss(sys); |
60 error("sysdisc: expecting discrete states and/or continous outputs"); | 64 if(!isempty(st_d) ) |
61 elseif (isempty(st_d)) | 65 Add = aa( st_d , st_d); |
62 warning("sysdisc: no discrete states"); | 66 stname = sysgetsignals(sys,"st",st_d); |
63 elseif(isempty(y_d)) | 67 Bdd = bb( st_d , :); |
64 warning("sysdisc: no discrete outputs"); | 68 if(!isempty(st_c)) |
65 endif | |
66 | |
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); | 69 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 = []; | |
80 endif | 70 endif |
81 if(!isempty(y_d)) | 71 if(!isempty(y_d)) |
82 Ddd = dd(y_d , :); | 72 Cdd = cc(y_d , st_d); |
83 outname = sysgetsignals(sys,"out",y_d); | 73 endif |
84 if(!isempty(st_c)) | 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)) | |
85 Cdc = cc(y_d , st_c); | 81 Cdc = cc(y_d , st_c); |
86 endif | |
87 else | |
88 outname=[]; | |
89 endif | 82 endif |
90 inname = sysgetsignals(sys,"in"); | 83 else |
91 outlist = 1:rows(outname); | 84 outname=[]; |
85 endif | |
86 inname = sysgetsignals(sys,"in"); | |
87 outlist = 1:rows(outname); | |
92 | 88 |
93 if(!isempty(outname)) | 89 if(!isempty(outname)) |
94 tsam = sysgettsam(sys); | 90 tsam = sysgettsam(sys); |
95 [nc,nz] = sysdimensions(sys); | 91 [nc,nz] = sysdimensions(sys); |
96 dsys = ss(Add,Bdd,Cdd,Ddd,tsam,0,nz,stname,inname,outname,outlist); | 92 dsys = ss(Add,Bdd,Cdd,Ddd,tsam,0,nz,stname,inname,outname,outlist); |
97 else | 93 else |
98 dsys=[]; | 94 dsys=[]; |
99 endif | 95 endif |
100 | |
101 unwind_protect_cleanup | |
102 warn_empty_list_elements = save_warn_empty_list_elements; | |
103 end_unwind_protect | |
104 | 96 |
105 endfunction | 97 endfunction |