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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
## 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} =} sysscale (@var{sys}, @var{outscale}, @var{inscale}, @var{outname}, @var{inname})
## scale inputs/outputs of a system.
##
## @strong{Inputs}
## @table @var
## @item sys
## Structured system.
## @item outscale
## @itemx inscale
## Constant matrices of appropriate dimension.
## @item outname
## @itemx inname
## Lists of strings with the names of respectively outputs and inputs.
## @end table
##
## @strong{Output}
## @table @var
## @item retsys
## resulting open loop system:
## @smallexample
## ----------- ------- -----------
## u --->| inscale |--->| sys |--->| outscale |---> y
## ----------- ------- -----------
## @end smallexample
## @end table
## If the input names and output names (each a list of strings)
## are not given and the scaling matrices
## are not square, then default names will be given to the inputs and/or
## outputs.
##
## A warning message is printed if outscale attempts to add continuous
## system outputs to discrete system outputs; otherwise @var{yd} is
## set appropriately in the returned value of @var{sys}.
## @end deftypefn
## Author: A. S. Hodel <a.s.hodel@eng.auburn.edu>
## Created: August 1995
## modified by John Ingram 7-15-96
function sys = sysscale (sys, outscale, inscale, outname, inname)
if (nargin < 3 || nargin > 5)
print_usage ();
elseif (! isstruct (sys))
error ("sys must be a structured system");
endif
[nn, nz, mm, pp] = sysdimensions (sys);
## check for omitted scales
if (isempty (outscale))
outscale = eye (pp);
endif
if (isempty (inscale))
inscale = eye (mm);
endif
## check dimensions of scaling matrices
if (mm != rows (inscale))
error ("inscale(%dx%d) should have %d rows(# system inputs)",
rows (inscale), columns (inscale), mm);
elseif (pp != columns (outscale) )
error ("outscale(%dx%d) should have %d columns(# system outputs)",
rows (outscale), columns (outscale), pp);
endif
sysyd = sysgetsignals (sys, "yd");
outc = find (sysyd == 0);
outd = find (sysyd == 1);
if (length (outc) > 0 && length (outd) > 0)
for ii = 1:rows(outscale)
nci = norm (outscale (ii, outc));
ndi = norm (outscale (ii, outd));
if (nci > 0 && ndi > 0)
warning ("sysscale: outscale(%d,:) sums continuous and discrete outputs; setting output to cont",
ii)
sysyd(ii) = 0;
else
sysyd(ii) = (ndi != 0);
endif
endfor
else
sysyd = ones (1, rows (outscale)) * (length(outd) > 0);
endif
## check for SISO system type
if (strcmp (sysgettype (sys), "tf"))
[num, den, tsam, innam, outnam] = sys2tf (sys);
num = num*inscale*outscale;
sys = tf (num, den, tsam, innam, outnam);
return;
elseif (strcmp (sysgettype (sys), "zp"))
[zer, pol, kk, tsam, innam, outnam] = sys2zp (sys);
kk = kk*inscale*outscale;
sys = zp (zer, pol, k, tsam, innam, outnam);
return;
endif
## it's a state space system...
[sysa, sysb, sysc, sysd, systsam, ...
sysn, sysnz, sysstname, sysinname, sysoutname, oldyd] = sys2ss(sys);
sysb = sysb*inscale;
sysc = outscale*sysc;
sysd = outscale*sysd*inscale;
if (! issquare (outscale))
## strip extra output names (if any)
sysoutname = sysoutname(1:min(rows(outscale), columns(outscale)));
if (nargin < 4)
warning ("sysscale: outscale not square, outname not specified");
warning ("sysscale: using default output names");
outname = __sysdefioname__ (rows (sysc), "y");
endif
else
outname = sysoutname;
endif
if (! issquare (inscale))
## strip extra output names (if any)
sysinname = sysinname(1:min(rows(inscale), columns(inscale)));
if (nargin < 5)
warning ("sysscale: inscale not square, inname not specified");
warning ("sysscale: using default input names");
inname = __sysdefioname__ (columns (sysb), "u");
endif
else
inname = sysgetsignals (sys, "in");
endif
sys = ss (sysa, sysb, sysc, sysd, systsam, nn, nz, sysstname,
inname, outname, find (sysyd == 1));
endfunction
|