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%2Fsize.m;fp=octave_packages%2Fcontrol-2.3.52%2F%40lti%2Fsize.m;h=e8f1a79f7f7772c739c6095f0f0e3764e2d95ab9;hp=0000000000000000000000000000000000000000;hb=f5f7a74bd8a4900f0b797da6783be80e11a68d86;hpb=1705066eceaaea976f010f669ce8e972f3734b05 diff --git a/octave_packages/control-2.3.52/@lti/size.m b/octave_packages/control-2.3.52/@lti/size.m new file mode 100644 index 0000000..e8f1a79 --- /dev/null +++ b/octave_packages/control-2.3.52/@lti/size.m @@ -0,0 +1,91 @@ +## Copyright (C) 2009, 2011 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{nvec} =} size (@var{sys}) +## @deftypefnx {Function File} {@var{n} =} size (@var{sys}, @var{dim}) +## @deftypefnx {Function File} {[@var{p}, @var{m}] =} size (@var{sys}) +## LTI model size, i.e. number of outputs and inputs. +## +## @strong{Inputs} +## @table @var +## @item sys +## LTI system. +## @item dim +## If given a second argument, @command{size} will return the size of the +## corresponding dimension. +## @end table +## +## @strong{Outputs} +## @table @var +## @item nvec +## Row vector. The first element is the number of outputs (rows) and the second +## element the number of inputs (columns). +## @item n +## Scalar value. The size of the dimension @var{dim}. +## @item p +## Number of outputs. +## @item m +## Number of inputs. +## @end table +## @end deftypefn + +## Author: Lukas Reichlin +## Created: September 2009 +## Version: 0.2 + +function [n, varargout] = size (sys, dim = 0) + + if (nargin > 2) + print_usage (); + endif + + p = numel (sys.outname); # WARNING: system matrices may change without + m = numel (sys.inname); # being noticed by the i/o names! + + switch (dim) + case 0 + switch (nargout) + case 0 + if (p == 1) + stry = ""; + else + stry = "s"; + endif + if (m == 1) + stru = ""; + else + stru = "s"; + endif + disp (sprintf ("LTI model with %d output%s and %d input%s.", p, stry, m, stru)); + case 1 + n = [p, m]; + case 2 + n = p; + varargout{1} = m; + otherwise + print_usage (); + endswitch + case 1 + n = p; + case 2 + n = m; + otherwise + print_usage (); + endswitch + +endfunction