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