/usr/share/octave/packages/control-2.6.2/@lti/series.m is in octave-control 2.6.2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | ## Copyright (C) 2009-2014 Lukas F. Reichlin
##
## This file is part of LTI Syncope.
##
## LTI Syncope 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.
##
## LTI Syncope 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 LTI Syncope. If not, see <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} {@var{sys} =} series (@var{sys1}, @var{sys2})
## @deftypefnx {Function File} {@var{sys} =} series (@var{sys1}, @var{sys2}, @var{outputs1}, @var{inputs2})
## Series connection of two @acronym{LTI} models.
##
## @strong{Block Diagram}
## @example
## @group
## .....................................
## u : +--------+ y1 u2 +--------+ : y
## ------>| sys1 |---------->| sys2 |------->
## : +--------+ +--------+ :
## :................sys.................
##
## sys = series (sys1, sys2)
## @end group
## @end example
## @example
## @group
## .....................................
## : v2 +--------+ :
## : ---------->| | : y
## : +--------+ y1 u2 | sys2 |------->
## u : | |---------->| | :
## ------>| sys1 | z1 +--------+ :
## : | |----------> :
## : +--------+ :
## :................sys.................
##
## outputs1 = [1]
## inputs2 = [2]
## sys = series (sys1, sys2, outputs1, inputs2)
## @end group
## @end example
## @end deftypefn
## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
## Created: September 2009
## Version: 0.2
function sys = series (sys1, sys2, out1, in2)
if (nargin == 2)
sys = sys2 * sys1;
elseif (nargin == 4)
[p1, m1] = size (sys1);
[p2, m2] = size (sys2);
if (! is_real_vector (out1))
error ("series: argument 3 (outputs1) invalid");
endif
if (! is_real_vector (in2))
error ("series: argument 4 (inputs2) invalid");
endif
l_out1 = length (out1);
l_in2 = length (in2);
if (l_out1 > p1)
error ("series: 'outputs1' has too many indices for 'sys1'");
endif
if (l_in2 > m2)
error ("series: 'inputs2' has too many indices for 'sys2'");
endif
if (l_out1 != l_in2)
error ("series: number of 'outputs1' and 'inputs2' indices must be equal");
endif
if (any (out1 > m1 | out1 < 1))
error ("series: range of 'outputs1' indices exceeds dimensions of 'sys1'");
endif
if (any (in2 > p1 | in2 < 1))
error ("series: range of 'inputs2' indices exceeds dimensions of 'sys2'");
endif
out_scl = full (sparse (1:l_out1, out1, 1, l_out1, p1));
in_scl = full (sparse (in2, 1:l_out1, 1, m2, l_in2));
## NOTE: for-loop does NOT the same as
## out_scl(1:l_out1, out1) = 1;
## in_scl(in2, 1:l_out1) = 1;
##
## out_scl = zeros (l_out1, p1);
## in_scl = zeros (m2, l_in2);
##
## for k = 1 : l_out1
## out_scl(k, out1(k)) = 1;
## in_scl(in2(k), k) = 1;
## endfor
scl = in_scl * out_scl;
sys = sys2 * scl * sys1;
else
print_usage ();
endif
endfunction
|