1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
|
## Copyright (C) 1996, 1998, 2000, 2002, 2004, 2005, 2006, 2007
## Auburn University. All rights reserved.
##
##
## This program is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or (at
## your option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; see the file COPYING. If not, see
## <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {@var{retsys} =} sysdup (@var{asys}, @var{out_idx}, @var{in_idx})
## Duplicate specified input/output connections of a system
##
## @strong{Inputs}
## @table @var
## @item asys
## system data structure
## @item out_idx
## @itemx in_idx
## indices or names of desired signals (see @code{sigidx}).
## duplicates are made of @code{y(out_idx(ii))} and @code{u(in_idx(ii))}.
## @end table
##
## @strong{Output}
## @table @var
## @item retsys
## Resulting closed loop system:
## duplicated i/o names are appended with a @code{"+"} suffix.
## @end table
##
## @strong{Method}
##
## @code{sysdup} creates copies of selected inputs and outputs as
## shown below. @var{u1}, @var{y1} is the set of original inputs/outputs, and
## @var{u2}, @var{y2} is the set of duplicated inputs/outputs in the order
## specified in @var{in_idx}, @var{out_idx}, respectively
## @example
## @group
## ____________________
## u1 ----->| |----> y1
## | asys |
## u2 ------>| |----->y2
## (in_idx) -------------------- (out_idx)
## @end group
## @end example
## @end deftypefn
## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu>
## Created: August 1995
## modified by John Ingram July 1996
function retsys = sysdup (Asys, output_list, input_list)
if (nargin != 3)
print_usage ();
endif
if (! isstruct (Asys))
error ("Asys must be a system data structure (see ss, tf, or zp)")
endif
Asys = sysupdate (Asys, "ss");
[nn, nz, mm, pp] = sysdimensions (Asys);
[aa, bb, cc, dd] = sys2ss (Asys);
## check for signal names
if (is_signal_list (input_list) || ischar (input_list))
input_list = sysidx (Asys, "in", input_list);
endif
if (is_signal_list (output_list) || ischar (output_list))
output_list = sysidx (Asys, "out", output_list);
endif
## first duplicate inputs
if (isvector (input_list))
for ii = 1:length(input_list);
bb(:,mm+ii) = bb(:,input_list(ii));
dd(:,mm+ii) = dd(:,input_list(ii));
endfor
elseif (! isempty (input_list))
error ("input_list must be a vector or empty");
endif
## now duplicate outputs
osize = min (size (output_list));
if (osize == 1)
for ii = 1:length(output_list);
cc(pp+ii,:) = cc(output_list(ii),:);
dd(pp+ii,:) = dd(output_list(ii),:);
endfor
elseif (osize != 0)
error ("output_list must be a vector or empty");
endif
[stnam, innam, outnam, yd] = sysgetsignals (Asys);
tsam = sysgettsam (Asys);
## pack system and then rename signals
retsys = ss (aa, bb, cc, dd, tsam, nn, nz);
retsys = syssetsignals (retsys, "in", innam, 1:mm);
retsys = syssetsignals (retsys, "out", outnam, 1:pp);
retsys = syssetsignals (retsys, "yd", yd, 1:pp);
## update added input names
for ii = (mm+1):(mm+length(input_list))
onum = input_list(ii-mm);
strval = sprintf ("%s(dup)", sysgetsignals (retsys, "in", onum, 1));
retsys = syssetsignals (retsys, "in", strval, ii);
endfor
## update added output names/discrete flags
## give default names to the added outputs
for jj = (pp+1):(pp+length(output_list))
onum = output_list(jj-pp);
strval = sprintf ("%s(dup)", sysgetsignals (retsys, "out", onum, 1));
retsys = syssetsignals (retsys, "out", strval, jj);
dflg = sysgetsignals (retsys, "yd", onum);
retsys = syssetsignals (retsys, "yd", dflg, jj);
endfor
endfunction
|