X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=CreaPhase.git;a=blobdiff_plain;f=octave_packages%2Fcontrol-2.3.52%2F%40lti%2Fconnect.m;fp=octave_packages%2Fcontrol-2.3.52%2F%40lti%2Fconnect.m;h=4d6b58e0b424fd48e12a2db599dd827cfa048cd3;hp=0000000000000000000000000000000000000000;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hpb=1705066eceaaea976f010f669ce8e972f3734b05 diff --git a/octave_packages/control-2.3.52/@lti/connect.m b/octave_packages/control-2.3.52/@lti/connect.m new file mode 100644 index 0000000..4d6b58e --- /dev/null +++ b/octave_packages/control-2.3.52/@lti/connect.m @@ -0,0 +1,59 @@ +## Copyright (C) 2009 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 . + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{sys} =} connect (@var{sys}, @var{cm}, @var{inputs}, @var{outputs}) +## Arbitrary interconnections between the inputs and outputs of an LTI model. +## @end deftypefn + +## Author: Lukas Reichlin +## Created: October 2009 +## Version: 0.1 + +function sys = connect (sys, cm, in_idx, out_idx) + + if (nargin != 4) + print_usage (); + endif + + [p, m] = size (sys); + [cmrows, cmcols] = size (cm); + + ## TODO: proper argument checking + ## TODO: name-based interconnections + ## TODO: replace nested for-if statement + + if (! is_real_matrix (cm)) + error ("connect: second argument must be a matrix with real coefficients"); + endif + + M = zeros (m, p); + in = cm(:, 1); + out = cm(:, 2:cmcols); + + for a = 1 : cmrows + for b = 1 : cmcols-1 + if (out(a, b) != 0) + M(in(a, 1), abs (out(a, b))) = sign (out(a, b)); + endif + endfor + endfor + + sys = __sys_connect__ (sys, M); + sys = __sys_prune__ (sys, out_idx, in_idx); + +endfunction \ No newline at end of file