Mercurial > hg > octave-terminal
changeset 3279:6dd06d525de6
[project @ 1999-10-12 16:52:40 by jwe]
line wrap: on
line diff
--- a/scripts/control/DEMOcontrol.m +++ b/scripts/control/DEMOcontrol.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All rights reserved. # # This file is part of Octave. #
--- a/scripts/control/abcddim.m +++ b/scripts/control/abcddim.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/abcddims.m +++ b/scripts/control/abcddims.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1997 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/analdemo.m +++ b/scripts/control/analdemo.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/are.m +++ b/scripts/control/are.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/axis2dlim.m +++ b/scripts/control/axis2dlim.m @@ -1,4 +1,4 @@ -# Copyright (C) 1998 A. Scottedward Hodel +# Copyright (C) 1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/bddemo.m +++ b/scripts/control/bddemo.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/bode.m +++ b/scripts/control/bode.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/bode_bounds.m +++ b/scripts/control/bode_bounds.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/bodquist.m +++ b/scripts/control/bodquist.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/com2str.m +++ b/scripts/control/com2str.m @@ -1,4 +1,4 @@ -# Copyright (C) 1998 A. Scottedward Hodel +# Copyright (C) 1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/controldemo.m +++ b/scripts/control/controldemo.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/d2c.m +++ b/scripts/control/d2c.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/dare.m +++ b/scripts/control/dare.m @@ -1,4 +1,4 @@ -## Copyright (C) 1996, 1997 John W. Eaton +## Copyright (C) 1996, 1997 Auburn University. All Rights Reserved. ## ## This file is part of Octave. ##
--- a/scripts/control/demomarsyas.m +++ b/scripts/control/demomarsyas.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/dgkfdemo.m +++ b/scripts/control/dgkfdemo.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/dgram.m +++ b/scripts/control/dgram.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/dlqe.m +++ b/scripts/control/dlqe.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/dlqg.m +++ b/scripts/control/dlqg.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/dlqr.m +++ b/scripts/control/dlqr.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/dlyap.m +++ b/scripts/control/dlyap.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/dmr2d.m +++ b/scripts/control/dmr2d.m @@ -1,4 +1,4 @@ -# Copyright (C) 1998 A. S. Hodel +# Copyright (C) 1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/dre.m +++ b/scripts/control/dre.m @@ -1,4 +1,4 @@ -# Copyright (C) 1998 A. Scottedward Hodel +# Copyright (C) 1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/fir2sys.m +++ b/scripts/control/fir2sys.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/frdemo.m +++ b/scripts/control/frdemo.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/freqchkw.m +++ b/scripts/control/freqchkw.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/freqresp.m +++ b/scripts/control/freqresp.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/gram.m +++ b/scripts/control/gram.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/h2norm.m +++ b/scripts/control/h2norm.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/h2syn.m +++ b/scripts/control/h2syn.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/hinf_ctr.m +++ b/scripts/control/hinf_ctr.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/hinfnorm.m +++ b/scripts/control/hinfnorm.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/hinfsyn.m +++ b/scripts/control/hinfsyn.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/hinfsyn_chk.m +++ b/scripts/control/hinfsyn_chk.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/hinfsyn_ric.m +++ b/scripts/control/hinfsyn_ric.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/impulse.m +++ b/scripts/control/impulse.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/is_controllable.m +++ b/scripts/control/is_controllable.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/is_detectable.m +++ b/scripts/control/is_detectable.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/is_dgkf.m +++ b/scripts/control/is_dgkf.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/is_digital.m +++ b/scripts/control/is_digital.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996, 1999 A. Scottedward Hodel +# Copyright (C) 1996, 1999 Auburn University. All Rights Reserved # # This file is part of Octave. # @@ -36,7 +36,7 @@ switch(nargin) case(1), eflg = 0; case(2), - if( isempty(find(eflg == [0 1 2])) ) + if( isempty(find(eflg == [0, 1, 2])) ) error("Illegal value of eflg=%d (%e)",eflg,eflg); endif otherwise,
--- a/scripts/control/is_observable.m +++ b/scripts/control/is_observable.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/is_sample.m +++ b/scripts/control/is_sample.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/is_signal_list.m +++ b/scripts/control/is_signal_list.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/is_siso.m +++ b/scripts/control/is_siso.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/is_stabilizable.m +++ b/scripts/control/is_stabilizable.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/is_stable.m +++ b/scripts/control/is_stable.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/lqe.m +++ b/scripts/control/lqe.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/lqg.m +++ b/scripts/control/lqg.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996, 1997 A. Scottedward Hodel +# Copyright (C) 1996, 1997 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/lqr.m +++ b/scripts/control/lqr.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993, 1994, 1995 John W. Eaton +# Copyright (C) 1993, 1994, 1995 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/lsim.m +++ b/scripts/control/lsim.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/ltifr.m +++ b/scripts/control/ltifr.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/lyap.m +++ b/scripts/control/lyap.m @@ -1,4 +1,4 @@ -## Copyright (C) 1996, 1997 John W. Eaton +## Copyright (C) 1996, 1997 Auburn University. All Rights Reserved ## ## This file is part of Octave. ##
--- a/scripts/control/mb.m +++ b/scripts/control/mb.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/minfo.m +++ b/scripts/control/minfo.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/moddemo.m +++ b/scripts/control/moddemo.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/nichols.m +++ b/scripts/control/nichols.m @@ -1,4 +1,4 @@ -# Copyright (C) 1998 A. Scottedward Hodel +# Copyright (C) 1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/nyquist.m +++ b/scripts/control/nyquist.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/outlist.m +++ b/scripts/control/outlist.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996, 1998 A. Scottedward Hodel +# Copyright (C) 1996, 1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/packedform.m +++ b/scripts/control/packedform.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/packsys.m +++ b/scripts/control/packsys.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/parallel.m +++ b/scripts/control/parallel.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/polyout.m +++ b/scripts/control/polyout.m @@ -1,4 +1,4 @@ -# Copyright (C) 1995,1998 A. Scottedward Hodel +# Copyright (C) 1995,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/prompt.m +++ b/scripts/control/prompt.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/pzmap.m +++ b/scripts/control/pzmap.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/qzval.m +++ b/scripts/control/qzval.m @@ -1,4 +1,4 @@ -# Copyright (C) 1998 A. Scottedward Hodel +# Copyright (C) 1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/rldemo.m +++ b/scripts/control/rldemo.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/rlocus.m +++ b/scripts/control/rlocus.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/rotg.m +++ b/scripts/control/rotg.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/run_cmd.m +++ b/scripts/control/run_cmd.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/series.m +++ b/scripts/control/series.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sortcom.m +++ b/scripts/control/sortcom.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/ss2sys.m +++ b/scripts/control/ss2sys.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. # @@ -105,6 +105,8 @@ # check for continuous states if( (nargin < 6) & (tsam == 0) ) n = na; elseif(nargin < 6) n = 0; + elseif((!is_matrix(n)) | isstr(n)) + error("Parameter n is not a numerical value."); elseif( (!is_scalar(n)) | (n < 0 ) | (n != round(n)) ) if(is_scalar(n)) error("illegal value of n=%d,%e",n,n); else error("illegal value of n=(%dx%d)", ... @@ -114,6 +116,8 @@ # check for num discrete states if( (nargin < 7) & (tsam == 0)) nz = 0; elseif(nargin < 7) nz = na - n; + elseif((!is_matrix(nz)) | isstr(nz)) + error("Parameter nz is not a numerical value."); elseif( (!is_scalar(nz)) | (nz < 0 ) | (nz != round(nz)) ) if(is_scalar(nz)) error(["illegal value of nz=",num2str(nz)]);
--- a/scripts/control/ss2tf.m +++ b/scripts/control/ss2tf.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/ss2zp.m +++ b/scripts/control/ss2zp.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/starp.m +++ b/scripts/control/starp.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/step.m +++ b/scripts/control/step.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/stepimp.m +++ b/scripts/control/stepimp.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/strappend.m +++ b/scripts/control/strappend.m @@ -1,4 +1,4 @@ -# Copyright (C) 1998 A. Scottedward Hodel +# Copyright (C) 1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/susball.m +++ b/scripts/control/susball.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/swap.m +++ b/scripts/control/swap.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/swapcols.m +++ b/scripts/control/swapcols.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/swaprows.m +++ b/scripts/control/swaprows.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sys2fir.m +++ b/scripts/control/sys2fir.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sys2ss.m +++ b/scripts/control/sys2ss.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996, 1998 A. Scottedward Hodel +# Copyright (C) 1996, 1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sys2tf.m +++ b/scripts/control/sys2tf.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sys2zp.m +++ b/scripts/control/sys2zp.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysadd.m +++ b/scripts/control/sysadd.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996,1999 Auburn University. All Rights Reserved. # # This file is part of Octave. # @@ -16,16 +16,16 @@ # along with Octave; see the file COPYING. If not, write to the Free # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -function sys = sysadd(Gsys,Hsys) +function sys = sysadd(...) # -# [sys] = sysadd(Gsys,Hsys) -# +# sys = sysadd(Gsys{,Hsys,...}) # -# returns transfer function sys = Gsys + Hsys +# returns transfer function sys = Gsys + Hsys + ... # -# Method: Gsys and Hsys are connected in parallel -# The vector are connected to both systems; the outputs will be -# added. The names given to the system will be the G systems names. +# Method: sysgroup used to connect systems in parallel +# The input vector is connected to all systems; the outputs are summed. +# Returned system input/output signal names are those of Gsys. For +# example, sysadd(Gsys,Hsys) results in # # ________ # ----| Gsys |--- @@ -36,62 +36,78 @@ # -------- # Written by John Ingram July 1996 +# Updated for variable number of arguments July 1999 A. S. Hodel save_val = implicit_str_to_num_ok; # save for later implicit_str_to_num_ok = 1; - if(nargin != 2) - usage("sysadd: [sys] = sysysadd(Gsys,Hsys)"); - endif - - # check inputs - if(!is_struct(Gsys) | !is_struct(Hsys)) - error("Both Gsys and Hsys must be in system data structure form"); - endif - - # check for compatibility - [n,nz,mg,pg] = sysdimensions(Gsys); - [n,nz,mh,ph] = sysdimensions(Hsys); - if(mg != mh) - error(sprintf("Gsys inputs(%d) != Hsys inputs (%d)",mg,mh)); - elseif(pg != ph) - error(sprintf("Gsys outputs(%d) != Hsys outputs (%d)",pg,ph)); - endif - - [Gst, Gin, Gout, Gyd] = sysgetsignals(Gsys); - [Hst, Hin, Hout, Hyd] = sysgetsignals(Hsys); - - # check for digital to continuous addition - if (Gyd != Hyd) - error("can not add a discrete output to a continuous output"); + if(nargin < 1) + usage("sysadd: sys = sysysadd(Gsys{,Hsys, ...})"); endif - if( strcmp(sysgettype(Gsys),"tf") | strcmp(sysgettype(Hsys),"tf") ) - # see if adding transfer functions with identical denominators - [Gnum,Gden,GT,Gin,Gout] = sys2tf(Gsys); - [Hnum,Hden,HT,Hin,Hout] = sys2tf(Hsys); - if( (Hden == Gden) & (HT == GT) ) - sys = tf2sys(Gnum+Hnum,Gden,GT,Gin,Gout); - return + # collect all arguments + arglist = list(); + va_start(); + for kk=1:nargin + arglist(kk) = va_arg(); + if(!is_struct(nth(arglist,kk))) + error("sysadd: argument %d is not a data structure",kk); endif - # if not, we go on and do the usual thing... - endif + endfor - # make sure in ss form - Gsys = sysupdate(Gsys,"ss"); - Hsys = sysupdate(Hsys,"ss"); + # check system dimensions + [n,nz,mg,pg,Gyd] = sysdimensions(nth(arglist,1)); + for kk=2:nargin + [n,nz,mh,ph,Hyd] = sysdimensions(nth(arglist,kk)); + if(mg != mh) + error("arg 1 has %d inputs; arg %d has vs %d inputs",mg,kk,mh); + elseif(pg != ph) + error("arg 1 has %d outputs; arg %d has vs %d outputs",pg,kk,ph); + elseif(norm(Gyd - Hyd)) + warning("cannot add a discrete output to a continuous output"); + error("Output type mismatch: arguments 1 and %d\n",kk); + endif + endfor - # change signal names to avoid warning messages from sysgroup - Gsys = syssetsignals(Gsys,"in",sysdefioname(length(Gin),"Gin_u")); - Gsys = syssetsignals(Gsys,"out",sysdefioname(length(Gout),"Gout_u")); - Hsys = syssetsignals(Hsys,"in",sysdefioname(length(Hin),"Hin_u")); - Hsys = syssetsignals(Hsys,"out",sysdefioname(length(Hout),"Hout_u")); + # perform the add + if(nargin == 2) + Gsys = nth(arglist,1); Hsys = nth(arglist,2); + if( strcmp(sysgettype(Gsys),"tf") | strcmp(sysgettype(Hsys),"tf") ) + # see if adding transfer functions with identical denominators + [Gnum,Gden,GT,Gin,Gout] = sys2tf(Gsys); + [Hnum,Hden,HT,Hin,Hout] = sys2tf(Hsys); + if(length(Hden) == length(Gden) ) + if( (Hden == Gden) & (HT == GT) ) + sys = tf2sys(Gnum+Hnum,Gden,GT,Gin,Gout); + return + endif + # if not, we go on and do the usual thing... + endif + endif + + # make sure in ss form + Gsys = sysupdate(Gsys,"ss"); + Hsys = sysupdate(Hsys,"ss"); - sys = sysgroup(Gsys,Hsys); + # change signal names to avoid warning messages from sysgroup + Gsys = syssetsignals(Gsys,"in",sysdefioname(length(Gin),"Gin_u")); + Gsys = syssetsignals(Gsys,"out",sysdefioname(length(Gout),"Gout_u")); + Hsys = syssetsignals(Hsys,"in",sysdefioname(length(Hin),"Hin_u")); + Hsys = syssetsignals(Hsys,"out",sysdefioname(length(Hout),"Hout_u")); + + sys = sysgroup(Gsys,Hsys); + + eyin = eye(mg); + eyout = eye(pg); + + sys = sysscale(sys,[eyout, eyout],[eyin;eyin],Gout,Gin); + + else + # multiple systems (or a single system); combine together one by one + sys = nth(arglist,1); + for kk=2:length(arglist) + sys = sysadd(sys,nth(arglist,kk)); + endfor + endif +endfunction - eyin = eye(mg); - eyout = eye(pg); - - sys = sysscale(sys,[eyout, eyout],[eyin;eyin],Gout,Gin); - -endfunction
--- a/scripts/control/sysappend.m +++ b/scripts/control/sysappend.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/syschnames.m +++ b/scripts/control/syschnames.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/syschnamesl.m +++ b/scripts/control/syschnamesl.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. # @@ -25,8 +25,17 @@ # # combines the two string lists old_names and inames - # $Revision: 1.2 $ + # $Revision: 2.1.14.5 $ # $Log: syschnamesl.m,v $ +# Revision 2.1.14.5 1999/09/22 21:55:46 scotte +# Auburn copyright fixed; krylov.m patched to fix bug +# +# Revision 2.1.14.4 1999/07/21 19:49:21 scotte +# sysgroup, sysadd, sysmult, syssub accept variable # of input args +# + # Revision 1.3 1998/07/17 15:08:50 hodelas + # use isempty instead of max(size(...)) + # # Revision 1.2 1998/07/01 16:23:39 hodelas # Updated c2d, d2c to perform bilinear transforms. # Updated several files per bug updates from users.
--- a/scripts/control/syschtsam.m +++ b/scripts/control/syschtsam.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysconnect.m +++ b/scripts/control/sysconnect.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/syscont.m +++ b/scripts/control/syscont.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/syscont_disc.m +++ b/scripts/control/syscont_disc.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysdefioname.m +++ b/scripts/control/sysdefioname.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysdefstname.m +++ b/scripts/control/sysdefstname.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysdimensions.m +++ b/scripts/control/sysdimensions.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysdisc.m +++ b/scripts/control/sysdisc.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysdup.m +++ b/scripts/control/sysdup.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysgetsignals.m +++ b/scripts/control/sysgetsignals.m @@ -1,4 +1,4 @@ -# Copyright (C) 1998 A. Scottedward Hodel +# Copyright (C) 1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysgettsam.m +++ b/scripts/control/sysgettsam.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysgettype.m +++ b/scripts/control/sysgettype.m @@ -1,4 +1,4 @@ -# Copyright (C) 1998 A. Scottedward Hodel +# Copyright (C) 1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysgroup.m +++ b/scripts/control/sysgroup.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996, 1998, 1999 Auburn University. All Rights Reserved. # # This file is part of Octave. # @@ -16,12 +16,15 @@ # along with Octave; see the file COPYING. If not, write to the Free # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -function sys = sysgroup(Asys,Bsys) -# function sys = sysgroup(Asys,Bsys) -# Combines two system data structures into a single system +function sys = sysgroup(...) +# function sys = sysgroup(Asys{,Bsys,...}) +# Parallel connection of systems # -# input: Asys, Bsys: system data structures -# output: sys: Asys and Bsys are combined into a single system: +# inputs: All input arguments must be system data structures; +# exits with an error if there is not at least one argument +# output: sys: all systems are combined into a single system; e.g., +# if two systems are passed as sysgroup(Asys,Bsys), the result +# is # # __________________ # | ________ | @@ -36,10 +39,11 @@ # The function also rearranges the A,B,C matrices so that the # continuous states come first and the discrete states come last. # If there are duplicate names, the second name has a unique suffix appended -# on to the end of the name. +# on to the end of the name (a warning message is printed). # A. S. Hodel August 1995 # modified by John Ingram July 1996 +# A. S. Hodel: modified for variable number of arguments 1999 save_val = implicit_str_to_num_ok; # save for later implicit_str_to_num_ok = 1; @@ -47,75 +51,98 @@ save_emp = empty_list_elements_ok; empty_list_elements_ok = 1; - if(nargin ~= 2) - usage("sys = sysgroup(Asys,Bsys)"); - elseif( !is_struct(Asys) | !is_struct(Bsys) ) - error("sysgroup: input arguments must both be structured systems"); - endif - - # extract information from Asys, Bsys to consruct sys - Asys = sysupdate(Asys,"ss"); - Bsys = sysupdate(Bsys,"ss"); - [n1,nz1,m1,p1] = sysdimensions(Asys); - [n2,nz2,m2,p2] = sysdimensions(Bsys); - [Aa,Ab,Ac,Ad,Atsam,An,Anz,Ast,Ain,Aout,Ayd] = sys2ss(Asys); - [Ba,Bb,Bc,Bd,Btsam,Bn,Bnz,Bst,Bin,Bout,Byd] = sys2ss(Bsys); - nA = An + Anz; - nB = Bn + Bnz; - - if(p1*m1*p2*m2 == 0) - error("sysgroup: argument lacks inputs and/or outputs"); - - elseif((Atsam + Btsam > 0) & (Atsam * Btsam == 0) ) - warning("sysgroup: creating combination of continuous and discrete systems") - - elseif(Atsam != Btsam) - error("sysgroup: Asys.tsam=%e, Bsys.tsam =%e", Atsam, Btsam); + + if(nargin < 1) + usage("sys = sysgroup(Asys{,Bsys,...})"); endif - A = [Aa,zeros(nA,nB); zeros(nB,nA),Ba]; - B = [Ab,zeros(nA,m2); zeros(nB,m1),Bb]; - C = [Ac,zeros(p1,nB); zeros(p2,nA),Bc]; - D = [Ad,zeros(p1,m2); zeros(p2,m1),Bd]; - tsam = max(Atsam,Btsam); - - # construct combined signal names; stnames must check for pure gain blocks - if(isempty(Ast)) - stname = Bst; - elseif(isempty(Bst)) - stname = Ast; - else - stname = append(Ast, Bst); - endif - inname = append(Ain, Bin); - outname = append(Aout,Bout); + # collect all arguments + arglist = list(); + va_start(); + for kk=1:nargin + arglist(kk) = va_arg(); + if(!is_struct(nth(arglist,kk))) + error("sysgroup: argument %d is not a data structure",kk); + endif + endfor - # Sort states into continous first, then discrete - dstates = ones(1,(nA+nB)); - if(An) - dstates(1:(An)) = zeros(1,An); - endif - if(Bn) - dstates((nA+1):(nA+Bn)) = zeros(1,Bn); + if(nargin == 2) + # the usual case; group the two systems together + Asys = nth(arglist,1); + Bsys = nth(arglist,2); + + # extract information from Asys, Bsys to consruct sys + Asys = sysupdate(Asys,"ss"); + Bsys = sysupdate(Bsys,"ss"); + [n1,nz1,m1,p1] = sysdimensions(Asys); + [n2,nz2,m2,p2] = sysdimensions(Bsys); + [Aa,Ab,Ac,Ad,Atsam,An,Anz,Ast,Ain,Aout,Ayd] = sys2ss(Asys); + [Ba,Bb,Bc,Bd,Btsam,Bn,Bnz,Bst,Bin,Bout,Byd] = sys2ss(Bsys); + nA = An + Anz; + nB = Bn + Bnz; + + if(p1*m1*p2*m2 == 0) + error("sysgroup: argument lacks inputs and/or outputs"); + + elseif((Atsam + Btsam > 0) & (Atsam * Btsam == 0) ) + warning("sysgroup: creating combination of continuous and discrete systems") + + elseif(Atsam != Btsam) + error("sysgroup: Asys.tsam=%e, Bsys.tsam =%e", Atsam, Btsam); + endif + + A = [Aa,zeros(nA,nB); zeros(nB,nA),Ba]; + B = [Ab,zeros(nA,m2); zeros(nB,m1),Bb]; + C = [Ac,zeros(p1,nB); zeros(p2,nA),Bc]; + D = [Ad,zeros(p1,m2); zeros(p2,m1),Bd]; + tsam = max(Atsam,Btsam); + + # construct combined signal names; stnames must check for pure gain blocks + if(isempty(Ast)) + stname = Bst; + elseif(isempty(Bst)) + stname = Ast; + else + stname = append(Ast, Bst); + endif + inname = append(Ain, Bin); + outname = append(Aout,Bout); + + # Sort states into continous first, then discrete + dstates = ones(1,(nA+nB)); + if(An) + dstates(1:(An)) = zeros(1,An); + endif + if(Bn) + dstates((nA+1):(nA+Bn)) = zeros(1,Bn); + endif + [tmp,pv] = sort(dstates); + A = A(pv,pv); + B = B(pv,:); + C = C(:,pv); + stname = stname(pv); + + # check for duplicate signal names + inname = sysgroupn(inname,"input"); + stname = sysgroupn(stname,"state"); + outname = sysgroupn(outname,"output"); + + # mark discrete outputs + outlist = find([Ayd, Byd]); + + # build new system + sys = ss2sys(A,B,C,D,tsam,An+Bn,Anz+Bnz,stname,inname,outname); + + else + # multiple systems (or a single system); combine together one by one + sys = nth(arglist,1); + for kk=2:length(arglist) + printf("sysgroup: kk=%d\n",kk); + sys = sysgroup(sys,nth(arglist,kk)); + endfor endif - [tmp,pv] = sort(dstates); - A = A(pv,pv); - B = B(pv,:); - C = C(:,pv); - stname = stname(pv); - - # check for duplicate signal names - inname = sysgroupn(inname,"input"); - stname = sysgroupn(stname,"state"); - outname = sysgroupn(outname,"output"); - - # mark discrete outputs - outlist = find([Ayd, Byd]); - - # build new system - sys = ss2sys(A,B,C,D,tsam,An+Bn,Anz+Bnz,stname,inname,outname); - + implicit_str_to_num_ok = save_val; # restore value empty_list_elements_ok = save_emp; - + endfunction
--- a/scripts/control/sysgroupn.m +++ b/scripts/control/sysgroupn.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved. # # This file is part of Octave. #
--- a/scripts/control/sysidx.m +++ b/scripts/control/sysidx.m @@ -1,3 +1,24 @@ +# Copyright (C) 1999 Auburn University. All rights reserved. +# +# This file is part of Octave. +# +# Octave 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 2, or (at your option) any +# later version. +# +# Octave 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 Octave; see the file COPYING. If not, write to the Free +# Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Written by A. S. Hodel, a.s.hodel@eng.auburn.edu + + function idxvec = sysidx(sys,sigtype,signamelist) # idxvec = sysidx(sys,sigtype,signamelist) # return indices of signals with specified signal names
--- a/scripts/control/sysmin.m +++ b/scripts/control/sysmin.m @@ -1,3 +1,23 @@ +# Copyright (C) 1996 Auburn University. All rights reserved. +# +# This file is part of Octave. +# +# Octave 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 2, or (at your option) any +# later version. +# +# Octave 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 Octave; see the file COPYING. If not, write to the Free +# Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. +# +# Written by A. S. Hodel a.s.hodel@eng.auburn.edu + function [retsys,nc,no,cflg,oflg] = sysmin(sys,flg); # [retsys,nc,no] = sysmin(sys{,flg}); # return a minimal (or reduced order) system
--- a/scripts/control/sysmult.m +++ b/scripts/control/sysmult.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996,1999 Auburn University. All Rights Reserved # # This file is part of Octave. # @@ -16,14 +16,14 @@ # along with Octave; see the file COPYING. If not, write to the Free # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -function [sys] = sysmult(Asys,Bsys) +function sys = sysmult(...) # -# [sys] = sysmult(Asys,Bsys) +# sys = sysmult(Asys{,Bsys,...}) # -# returns sys = Asys*Bsys +# returns transfer function sys = Asys*Bsys* ... # -# This function takes two systems, Asys and Bsys, and multiplies them together. -# This has the effect of connecting the outputs of Bsys to the inputs of Asys. +# Same as series connection of systems; for example, sysmult(Asys,Bsys) +# returns sys = Asys*Bsys with block diagram # # # u ---------- ---------- @@ -36,60 +36,82 @@ # does not recognize discrete inputs) # Written by John Ingram July 1996 +# updated for variable number of arguments by A. S. Hodel July 1999 save_val = implicit_str_to_num_ok; # save for later implicit_str_to_num_ok = 1; - if(nargin != 2) - usage("sysmult: [sys] = sysmult(Asys,Bsys)"); - endif - - # check inputs - if(!is_struct(Asys) | !is_struct(Bsys)) - error("Both Asys and Bsys must be in system data structure form") - endif - - # check for compatibility - [An,Anz,Am,Ap] = sysdimensions(Asys); - [Bn,Bnz,Bm,Bp] = sysdimensions(Bsys); - if(Bp != Am) - error(["Bsys has ",num2str(Bp)," outputs, Asys has ",num2str(Am), ... - " inputs; mismatch."]); + if(nargin < 1) + usage("sysmult: sys = sysmult(Asys{,Bsys,...})"); endif - [Aa,Ab,Ac,Ad,Atsam,An,Anz,Astname,Ainname,Aoutname,Ayd] = sys2ss(Asys); - [Ba,Bb,Bc,Bd,Btsam,Bn,Bnz,Bstname,Binname,Boutname,Byd] = sys2ss(Bsys); + # collect all arguments + arglist = list(); + va_start(); + for kk=1:nargin + arglist(kk) = va_arg(); + if(!is_struct(nth(arglist,kk))) + error("sysadd: argument %d is not a data structure",kk); + endif + endfor + + # check system dimensions + [n,nz,mg,pg,Gyd] = sysdimensions(nth(arglist,1)); + for kk=2:nargin + [n,nz,mh,ph,Hyd] = sysdimensions(nth(arglist,kk)); + if(mh != pg) + error("arg %d has %d outputs; arg %d has vs %d inputs",kk,ph,kk-1,mg); + endif + [n,nz,mg,pg,Gyd] = sysdimensions(nth(arglist,kk)); # for next iteration + endfor - if(Byd) - # check direct feed-through of inputs through discrete outputs - alist = find(Byd); - if(An) - bd = Ab(1:An)* Bd(alist,:); - if(norm(bd,1)) - warning("sysmult: inputs -> Bsys discrete outputs -> continous states of Asys"); + # perform the multiply + if(nargin == 2) + Asys = nth(arglist,1); Bsys = nth(arglist,2); + + [An,Anz,Am,Ap] = sysdimensions(Asys); + [Bn,Bnz,Bm,Bp] = sysdimensions(Bsys); + + [Aa,Ab,Ac,Ad,Atsam,An,Anz,Astname,Ainname,Aoutname,Ayd] = sys2ss(Asys); + [Ba,Bb,Bc,Bd,Btsam,Bn,Bnz,Bstname,Binname,Boutname,Byd] = sys2ss(Bsys); + + if(Byd) + # check direct feed-through of inputs through discrete outputs + alist = find(Byd); + if(An) + bd = Ab(1:An)* Bd(alist,:); + if(norm(bd,1)) + warning("sysmult: inputs -> Bsys discrete outputs -> continous states of Asys"); + endif + endif + # check direct feed-through of continuous state through discrete outputs + if(Bn) + bc = Ab(1:An)* Bc(alist,1:(Bn)); + if( norm(bc,1) ) + warning("sysmult: Bsys states -> Bsys discrete outputs -> continuous states of Asys"); + endif endif endif - # check direct feed-through of continuous state through discrete outputs - if(Bn) - bc = Ab(1:An)* Bc(alist,1:(Bn)); - if( norm(bc,1) ) - warning("sysmult: Bsys states -> Bsys discrete outputs -> continuous states of Asys"); - endif - endif - endif + + # change signal names to avoid spurious warnings from sysgroup + Asys = syssetsignals(Asys,"in",sysdefioname(Am,"A_sysmult_tmp_name")); + Bsys = syssetsignals(Bsys,"out",sysdefioname(Bp,"B_sysmult_tmp_name")); + + sys = sysgroup(Asys,Bsys); + + # connect outputs of B to inputs of A + sys = sysconnect(sys,Ap+(1:Bp),1:Am); + + # now keep only outputs of A and inputs of B + sys = sysprune(sys,1:Ap,Am+(1:Bm)); - # change signal names to avoid spurious warnings from sysgroup - Asys = syssetsignals(Asys,"in",sysdefioname(Am,"A_sysmult_tmp_name")); - Bsys = syssetsignals(Bsys,"out",sysdefioname(Bp,"B_sysmult_tmp_name")); - - sys = sysgroup(Asys,Bsys); - - # connect outputs of B to inputs of A - sys = sysconnect(sys,Ap+(1:Bp),1:Am); - - # now keep only outputs of A and inputs of B - sys = sysprune(sys,1:Ap,Am+(1:Bm)); - + else + # multiple systems (or a single system); combine together one by one + sys = nth(arglist,1); + for kk=2:length(arglist) + sys = sysmult(sys,nth(arglist,kk)); + endfor + endif implicit_str_to_num_ok = save_val; # restore value endfunction
--- a/scripts/control/sysout.m +++ b/scripts/control/sysout.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/sysprune.m +++ b/scripts/control/sysprune.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/sysreorder.m +++ b/scripts/control/sysreorder.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/sysrepdemo.m +++ b/scripts/control/sysrepdemo.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/sysscale.m +++ b/scripts/control/sysscale.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/syssetsignals.m +++ b/scripts/control/syssetsignals.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/syssub.m +++ b/scripts/control/syssub.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996,1999 Auburn University. All Rights Reserved # # This file is part of Octave. # @@ -16,16 +16,18 @@ # along with Octave; see the file COPYING. If not, write to the Free # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -function sys = syssub(Gsys,Hsys) +function sys = syssub(...) # -# [sys] = syssub(Gsys,Hsys) +# sys = syssub(Gsys{,Hsys, ...}) # +# returns transfer function sys = Gsys - Hsys - ... # -# returns transfer functin sys = Gsys - Hsys -# -# Method: Gsys and Hsys are connected in parallel -# The vector are connected to both systems; the outputs will be -# subtracted. The names given to the system will be the G systems names. +# Method: sysgroup used to connect systems in parallel +# The input vector is connected to all systems; the outputs of all +# systems are connected to a summing junction with the first system's +# outputs added, all other outputs subtracted. +# Returned system input/output signal names are those of Gsys. +# Example: syssub(Gsys, Hsys) results in # # ________ # ----| Gsys |--- @@ -36,61 +38,78 @@ # -------- # Written by John Ingram July 1996 +# updated for variable numbers of input arguments by July 1999 A. S. Hodel save_val = implicit_str_to_num_ok; # save for later implicit_str_to_num_ok = 1; - if(nargin != 2) - usage("syssub: [sys] = syssub(Gsys,Hsys)"); - endif - - # check inputs - if(!is_struct(Gsys) | !is_struct(Hsys)) - error("Both Gsys and Hsys must be a system data structure"); - endif - - # check for compatibility - [n,nz,mg,pg] = sysdimensions(Gsys); - [n,nz,mh,ph] = sysdimensions(Hsys); - if(mg != mh) - error(sprintf("Gsys inputs(%d) != Hsys inputs (%d)",mg,mh)); - elseif(pg != ph) - error(sprintf("Gsys outputs(%d) != Hsys outputs (%d)",pg,ph)); - endif - - [Gst, Gin, Gout, Gyd] = sysgetsignals(Gsys); - [Hst, Hin, Hout, Hyd] = sysgetsignals(Hsys); - - # check for digital to continuous addition - if (Gyd != Hyd) - error("can not add a discrete output to a continuous output"); + if(nargin < 1) + usage("syssub: sys = syssub(Gsys{,Hsys,...})"); endif - if( strcmp(sysgettype(Gsys),"tf") | strcmp(sysgettype(Hsys),"tf") ) - # see if adding transfer functions with identical denominators - [Gnum,Gden,GT,Gin,Gout] = sys2tf(Gsys); - [Hnum,Hden,HT,Hin,Hout] = sys2tf(Hsys); - if( (Hden == Gden) & (HT == GT) ) - sys = tf2sys(Gnum-Hnum,Gden,GT,Gin,Gout); - return + # collect all arguments + arglist = list(); + va_start(); + for kk=1:nargin + arglist(kk) = va_arg(); + if(!is_struct(nth(arglist,kk))) + error("syssub: argument %d is not a data structure",kk); endif - # if not, we go on and do the usual thing... - endif + endfor + + # check system dimensions + [n,nz,mg,pg,Gyd] = sysdimensions(nth(arglist,1)); + for kk=2:nargin + [n,nz,mh,ph,Hyd] = sysdimensions(nth(arglist,kk)); + if(mg != mh) + error("arg 1 has %d inputs; arg %d has vs %d inputs",mg,kk,mh); + elseif(pg != ph) + error("arg 1 has %d outputs; arg %d has vs %d outputs",pg,kk,ph); + elseif(norm(Gyd - Hyd)) + warning("cannot add a discrete output to a continuous output"); + error("Output type mismatch: arguments 1 and %d\n",kk); + endif + endfor - # make sure in ss form - Gsys = sysupdate(Gsys,"ss"); - Hsys = sysupdate(Hsys,"ss"); - - # change signal names to avoid warning messages from sysgroup - Gsys = syssetsignals(Gsys,"in",sysdefioname(length(Gin),"Gin_u")); - Gsys = syssetsignals(Gsys,"out",sysdefioname(length(Gout),"Gout_u")); - Hsys = syssetsignals(Hsys,"in",sysdefioname(length(Hin),"Hin_u")); - Hsys = syssetsignals(Hsys,"out",sysdefioname(length(Hout),"Hout_u")); + # perform the subtract + if(nargin == 2) + Gsys = nth(arglist,1); Hsys = nth(arglist,2); + if( strcmp(sysgettype(Gsys),"tf") | strcmp(sysgettype(Hsys),"tf") ) + # see if subtracting transfer functions with identical denominators + [Gnum,Gden,GT,Gin,Gout] = sys2tf(Gsys); + [Hnum,Hden,HT,Hin,Hout] = sys2tf(Hsys); + if(length(Hden) == length(Gden) ) + if( (Hden == Gden) & (HT == GT) ) + sys = tf2sys(Gnum+Hnum,Gden,GT,Gin,Gout); + return + endif + # if not, we go on and do the usual thing... + endif + endif + + # make sure in ss form + Gsys = sysupdate(Gsys,"ss"); + Hsys = sysupdate(Hsys,"ss"); - sys = sysgroup(Gsys,Hsys); - - eyin = eye(mg); eyout = eye(pg); - - sys = sysscale(sys,[eyout -eyout],[eyin;eyin],Gout,Gin); - + # change signal names to avoid warning messages from sysgroup + Gsys = syssetsignals(Gsys,"in",sysdefioname(length(Gin),"Gin_u")); + Gsys = syssetsignals(Gsys,"out",sysdefioname(length(Gout),"Gout_u")); + Hsys = syssetsignals(Hsys,"in",sysdefioname(length(Hin),"Hin_u")); + Hsys = syssetsignals(Hsys,"out",sysdefioname(length(Hout),"Hout_u")); + + sys = sysgroup(Gsys,Hsys); + + eyin = eye(mg); + eyout = eye(pg); + + sys = sysscale(sys,[eyout -eyout],[eyin;eyin],Gout,Gin); + + else + # multiple systems (or a single system); combine together one by one + sys = nth(arglist,1); + for kk=2:length(arglist) + sys = syssub(sys,nth(arglist,kk)); + endfor + endif + endfunction
--- a/scripts/control/sysupdate.m +++ b/scripts/control/sysupdate.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/tf2ss.m +++ b/scripts/control/tf2ss.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/tf2sys.m +++ b/scripts/control/tf2sys.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/tf2sysl.m +++ b/scripts/control/tf2sysl.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/tf2zp.m +++ b/scripts/control/tf2zp.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/tfout.m +++ b/scripts/control/tfout.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/tzero.m +++ b/scripts/control/tzero.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/tzero2.m +++ b/scripts/control/tzero2.m @@ -1,4 +1,4 @@ -# Copyright (C) 1993 John W. Eaton +# Copyright (C) 1993 Auburn University. All Rights Reserved # # This file is part of Octave. # @@ -41,19 +41,19 @@ fprintf (stderr, "tzero: number of inputs,outputs differ. squaring up"); if (p > m) fprintf (stderr, " by padding b and d with zeros."); - b = [b, zeros (n, p-m)]; - d = [d, zeros (p, p-m)]; + b = [b, (zeros (n, p-m))]; + d = [d, (zeros (p, p-m))]; m = p; else fprintf (stderr, " by padding c and d with zeros."); - c = [c; zeros (m-p, n)]; - d = [d; zeros (m-p, m)]; + c = [c; (zeros (m-p, n))]; + d = [d; (zeros (m-p, m))]; p = m; endif fprintf (stderr, "This is a kludge. Try again with SISO system."); endif ab = [-a, -b; c, d]; - bb = [eye (n), zeros (n, m); zeros (p, n), zeros (p, m)]; + bb = [(eye (n)), (zeros (n, m)); (zeros (p, n)), (zeros (p, m))]; [ab,bb] = balance (ab, bb); zr = -qz (ab, bb); else
--- a/scripts/control/unpacksys.m +++ b/scripts/control/unpacksys.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zgfmul.m +++ b/scripts/control/zgfmul.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zgfslv.m +++ b/scripts/control/zgfslv.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zginit.m +++ b/scripts/control/zginit.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zgpbal.m +++ b/scripts/control/zgpbal.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zgreduce.m +++ b/scripts/control/zgreduce.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zgrownorm.m +++ b/scripts/control/zgrownorm.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zgscal.m +++ b/scripts/control/zgscal.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zgsgiv.m +++ b/scripts/control/zgsgiv.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zgshsr.m +++ b/scripts/control/zgshsr.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zp2ss.m +++ b/scripts/control/zp2ss.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996 A. Scottedward Hodel +# Copyright (C) 1996 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zp2ssg2.m +++ b/scripts/control/zp2ssg2.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. #
--- a/scripts/control/zp2sys.m +++ b/scripts/control/zp2sys.m @@ -1,4 +1,4 @@ -# Copyright (C) 1996,1998 A. Scottedward Hodel +# Copyright (C) 1996,1998 Auburn University. All Rights Reserved # # This file is part of Octave. # @@ -41,12 +41,16 @@ if( ! (is_vector(zer) | isempty(zer) ) ) error("zer must be a vector or empty"); endif - zer = reshape(zer,1,length(zer)); # make it a row vector + if(!isempty(zer)) + zer = reshape(zer,1,length(zer)); # make it a row vector + endif if( ! (is_vector(pol) | isempty(pol))) error("pol must be a vector"); endif - pol = reshape(pol,1,length(pol)); + if(!isempty(pol)) + pol = reshape(pol,1,length(pol)); + endif if (! is_scalar(k)) error('k must be a scalar');