3430
|
1 ## Copyright (C) 1996, 1998 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 -*- |
5016
|
21 ## @deftypefn {Function File} {@var{retsys} =} sysdup (@var{asys}, @var{out_idx}, @var{in_idx}) |
3430
|
22 ## Duplicate specified input/output connections of a system |
|
23 ## |
|
24 ## @strong{Inputs} |
|
25 ## @table @var |
3502
|
26 ## @item asys |
3439
|
27 ## system data structure |
3430
|
28 ## @item out_idx |
|
29 ## @itemx in_idx |
3462
|
30 ## indices or names of desired signals (see @code{sigidx}). |
3430
|
31 ## duplicates are made of @code{y(out_idx(ii))} and @code{u(in_idx(ii))}. |
|
32 ## @end table |
|
33 ## |
5016
|
34 ## @strong{Output} |
|
35 ## @table @var |
|
36 ## @item retsys |
|
37 ## Resulting closed loop system: |
3430
|
38 ## duplicated i/o names are appended with a @code{"+"} suffix. |
5016
|
39 ## @end table |
3430
|
40 ## |
|
41 ## @strong{Method} |
5016
|
42 ## |
3430
|
43 ## @code{sysdup} creates copies of selected inputs and outputs as |
5016
|
44 ## shown below. @var{u1}, @var{y1} is the set of original inputs/outputs, and |
|
45 ## @var{u2}, @var{y2} is the set of duplicated inputs/outputs in the order |
|
46 ## specified in @var{in_idx}, @var{out_idx}, respectively |
3430
|
47 ## @example |
|
48 ## @group |
|
49 ## ____________________ |
|
50 ## u1 ----->| |----> y1 |
3502
|
51 ## | asys | |
3430
|
52 ## u2 ------>| |----->y2 |
5016
|
53 ## (in_idx) -------------------- (out_idx) |
3430
|
54 ## @end group |
|
55 ## @end example |
|
56 ## @end deftypefn |
|
57 |
|
58 ## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu> |
|
59 ## Created: August 1995 |
|
60 ## modified by John Ingram July 1996 |
|
61 |
|
62 function retsys = sysdup (Asys, output_list, input_list) |
|
63 |
|
64 if( nargin != 3) |
|
65 usage("retsys = sysdup(Asys,output_list,input_list)"); |
|
66 endif |
|
67 |
4030
|
68 if( !isstruct(Asys)) |
4771
|
69 error("Asys must be a system data structure (see ss, tf, or zp)") |
3430
|
70 endif |
|
71 |
|
72 Asys = sysupdate(Asys,"ss"); |
|
73 [nn,nz,mm,pp] = sysdimensions(Asys); |
|
74 [aa,bb,cc,dd] = sys2ss(Asys); |
|
75 |
3462
|
76 ## check for signal names |
5443
|
77 if(is_signal_list(input_list) | ischar(input_list)) |
3462
|
78 input_list = sysidx(Asys,"in",input_list); |
|
79 endif |
5443
|
80 if(is_signal_list(output_list) | ischar(output_list)) |
3462
|
81 output_list = sysidx(Asys,"out",output_list); |
|
82 endif |
|
83 |
3430
|
84 ## first duplicate inputs |
4030
|
85 if(isvector(input_list)) |
3430
|
86 for ii=1:length(input_list); |
|
87 bb(:,mm+ii) = bb(:,input_list(ii)); |
|
88 dd(:,mm+ii) = dd(:,input_list(ii)); |
|
89 end |
|
90 elseif(!isempty(input_list)) |
|
91 error("input_list must be a vector or empty"); |
|
92 endif |
|
93 |
|
94 |
|
95 ## now duplicate outputs |
|
96 osize = min(size(output_list)); |
|
97 if(osize == 1) |
|
98 for ii=1:length(output_list); |
|
99 cc(pp+ii,:) = cc(output_list(ii),:); |
|
100 dd(pp+ii,:) = dd(output_list(ii),:); |
|
101 end |
|
102 elseif(osize != 0) |
|
103 error("output_list must be a vector or empty"); |
|
104 endif |
|
105 |
|
106 [stnam,innam,outnam,yd] = sysgetsignals(Asys); |
|
107 tsam = sysgettsam(Asys); |
|
108 |
|
109 ## pack system and then rename signals |
4771
|
110 retsys = ss(aa,bb,cc,dd,tsam,nn,nz); |
3430
|
111 retsys = syssetsignals(retsys,"in",innam,1:mm); |
|
112 retsys = syssetsignals(retsys,"out",outnam,1:pp); |
|
113 retsys = syssetsignals(retsys,"yd",yd,1:pp); |
|
114 |
|
115 ## update added input names |
|
116 for ii=(mm+1):(mm+length(input_list)) |
|
117 onum = input_list(ii-mm); |
|
118 strval = sprintf("%s(dup)",sysgetsignals(retsys,"in",onum,1) ); |
|
119 retsys = syssetsignals(retsys,"in",strval,ii); |
|
120 endfor |
|
121 |
|
122 ## update added output names/discrete flags |
|
123 ## give default names to the added outputs |
|
124 for jj=(pp+1):(pp+length(output_list)) |
|
125 onum = output_list(jj-pp); |
|
126 strval = sprintf("%s(dup)",sysgetsignals(retsys,"out",onum,1) ); |
|
127 retsys = syssetsignals(retsys,"out",strval,jj); |
|
128 dflg = sysgetsignals(retsys,"yd",onum); |
|
129 retsys = syssetsignals(retsys,"yd",dflg,jj); |
|
130 endfor |
|
131 |
|
132 endfunction |