Mercurial > hg > octave-lyh
comparison scripts/control/system/dmr2d.m @ 3462:04aef7306dca
[project @ 2000-01-19 17:16:43 by hodelas]
Updated to accept signal names or signal indices as inputs (calls to
either sysidx or listidx)
author | hodelas |
---|---|
date | Wed, 19 Jan 2000 17:16:45 +0000 |
parents | 99ab64f4a09d |
children | 7923abdeb4e5 |
comparison
equal
deleted
inserted
replaced
3461:1f2ce6b49c57 | 3462:04aef7306dca |
---|---|
26 ## @table @var | 26 ## @table @var |
27 ## @item sys | 27 ## @item sys |
28 ## discrete time system; | 28 ## discrete time system; |
29 ## @code{dmr2d} exits with an error if @var{sys} is not discrete | 29 ## @code{dmr2d} exits with an error if @var{sys} is not discrete |
30 ## @item idx | 30 ## @item idx |
31 ## list of states with sampling time @code{sysgettsam(@var{sys})} (may | 31 ## indices or names of states with sampling time |
32 ## be empty) | 32 ## @code{sysgettsam(@var{sys})} (may be empty); see @code{listidx} |
33 ## @item sprefix | 33 ## @item sprefix |
34 ## list of string prefixes of states with sampling time | 34 ## list of string prefixes of states with sampling time |
35 ## @code{sysgettsam(@var{sys})} | 35 ## @code{sysgettsam(@var{sys})} (may be empty) |
36 ## (may be empty) | |
37 ## @item Ts2 | 36 ## @item Ts2 |
38 ## sampling time of states not specified by @var{idx}, @var{sprefix} | 37 ## sampling time of states not specified by @var{idx}, @var{sprefix} |
39 ## must be an integer multiple of @code{sysgettsam(@var{sys})} | 38 ## must be an integer multiple of @code{sysgettsam(@var{sys})} |
40 ## @item cuflg | 39 ## @item cuflg |
41 ## "constant u flag" if @var{cuflg} is nonzero then the system inputs are | 40 ## "constant u flag" if @var{cuflg} is nonzero then the system inputs are |
82 elseif (!is_struct(sys)) | 81 elseif (!is_struct(sys)) |
83 error("sys must be in system data structure form"); | 82 error("sys must be in system data structure form"); |
84 | 83 |
85 elseif(!is_digital(sys)) | 84 elseif(!is_digital(sys)) |
86 error("sys must be discrete-time; continuous time passed"); | 85 error("sys must be discrete-time; continuous time passed"); |
86 | |
87 endif | |
88 | |
89 if(is_signal_list(idx) | isstr(idx)) | |
90 idx = sysidx(sys,"st",idx); | |
87 | 91 |
88 elseif (!(is_vector(idx) | isempty(idx))) | 92 elseif (!(is_vector(idx) | isempty(idx))) |
89 error(["idx(",num2str(rows(idx)),"x",num2str(columns(idx)), ... | 93 error(["idx(",num2str(rows(idx)),"x",num2str(columns(idx)), ... |
90 ") must be a vector"]); | 94 ") must be a vector"]); |
91 | 95 |
115 ## extract state space information | 119 ## extract state space information |
116 [da,db,dc,dd,Ts1,nc,nz,stname,inname,outname,yd] = sys2ss(sys); | 120 [da,db,dc,dd,Ts1,nc,nz,stname,inname,outname,yd] = sys2ss(sys); |
117 | 121 |
118 ## compute number of steps | 122 ## compute number of steps |
119 if(Ts1 > Ts2) | 123 if(Ts1 > Ts2) |
120 error(["Current sampling time=",num2str(Ts1),"< Ts2=",num2str(Ts2)]); | 124 error(["Current sampling time=",num2str(Ts1)," > Ts2=",num2str(Ts2)]); |
121 endif | 125 endif |
122 nstp = floor(Ts2/Ts1+0.5); | 126 nstp = floor(Ts2/Ts1+0.5); |
123 if(abs((Ts2 - Ts1*nstp)/Ts1) > 1e-12) | 127 if(abs((Ts2 - Ts1*nstp)/Ts1) > 1e-12) |
124 warning(["dmr2d: Ts1=",num2str(Ts1),", Ts2=",num2str(Ts2), ... | 128 warning(["dmr2d: Ts1=",num2str(Ts1),", Ts2=",num2str(Ts2), ... |
125 ", selecting nsteps=",num2str(nstp),"; mismatch"]); | 129 ", selecting nsteps=",num2str(nstp),"; mismatch"]); |
170 pvi = (Inz(pv,:)'*[1:nz]')'; | 174 pvi = (Inz(pv,:)'*[1:nz]')'; |
171 | 175 |
172 ## permute A, B (stname permuted for debugging only) | 176 ## permute A, B (stname permuted for debugging only) |
173 da = da(pv,pv); | 177 da = da(pv,pv); |
174 db = db(pv,:); | 178 db = db(pv,:); |
175 stname = stname(pv,:); | 179 stname = stname(pv); |
176 | 180 |
177 ## partition A, B: | 181 ## partition A, B: |
178 lfidx = length(fidx); | 182 lfidx = length(fidx); |
179 bki = 1:lfidx; | 183 bki = 1:lfidx; |
180 a11 = da(bki,bki); | 184 a11 = da(bki,bki); |
249 da(bki,bki2) = a12b; | 253 da(bki,bki2) = a12b; |
250 endif | 254 endif |
251 | 255 |
252 da = da(pvi,pvi); | 256 da = da(pvi,pvi); |
253 db = db(pvi,:); | 257 db = db(pvi,:); |
254 stname = stname(pvi,:); | 258 stname = stname(pvi); |
255 | 259 |
256 ## construct new system and return | 260 ## construct new system and return |
257 dsys = ss2sys(da,db,dc,dd,Ts2,0,nz,stname,inname,outname,find(yd == 1)); | 261 dsys = ss2sys(da,db,dc,dd,Ts2,0,nz,stname,inname,outname,find(yd == 1)); |
258 | 262 |
259 endfunction | 263 endfunction |