home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21eb.zip / octave / SCRIPTS.ZIP / scripts / control / step.m < prev    next >
Text File  |  1999-03-05  |  2KB  |  77 lines

  1. # Copyright (C) 1996 A. Scottedward Hodel
  2. #
  3. # This file is part of Octave. 
  4. #
  5. # Octave is free software; you can redistribute it and/or modify it 
  6. # under the terms of the GNU General Public License as published by the 
  7. # Free Software Foundation; either version 2, or (at your option) any 
  8. # later version. 
  9. # Octave is distributed in the hope that it will be useful, but WITHOUT 
  10. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  11. # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
  12. # for more details.
  13. # You should have received a copy of the GNU General Public License 
  14. # along with Octave; see the file COPYING.  If not, write to the Free 
  15. # Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  16.  
  17. function [y, t] = step(sys, inp, tstop, n)
  18. # step: Step response for a linear system.
  19. #       The system can be discrete or multivariable (or both).
  20. #
  21. # [y, t] = step(sys[, inp, tstop, n])
  22. # Produces a plot or the step response data for system sys.
  23. #
  24. # The argument tstop (scalar value) denotes the time when the
  25. # simulation should end. The Parameter n is the number of data values.
  26. # Both parameters tstop and n can be ommitted and will be
  27. # computed from the eigenvalues of the A-Matrix.
  28. #
  29. # When the step function is invoked with the output parameter y
  30. # a plot is not displayed.
  31. #
  32. # See also: impulse, stepimp
  33.  
  34. # Written by Kai P. Mueller September 30, 1997
  35. # based on lsim.m of Scottedward Hodel
  36. # modified by
  37.  
  38.   if((nargin < 1) || (nargin > 4))
  39.     usage("[y, u] = step(sys[, inp, tstop, n])");
  40.   endif
  41.  
  42.   if(nargout > 2)
  43.     usage("[y, u] = step(sys[, inp, tstop, n])");
  44.   endif
  45.  
  46.   if(!is_struct(sys))
  47.     error("step: sys must be a system data structure.");
  48.   endif
  49.  
  50.   if (nargout == 0)
  51.     switch (nargin)
  52.       case (1)
  53.         stepimp(1, sys);
  54.       case (2)
  55.         stepimp(1, sys, inp);
  56.       case (3)
  57.         stepimp(1, sys, inp, tstop);
  58.       case (4)
  59.         stepimp(1, sys, inp, tstop, n);
  60.     endswitch
  61.   else
  62.     switch (nargin)
  63.       case (1)
  64.         [y, t] = stepimp(1, sys);
  65.       case (2)
  66.         [y, t] = stepimp(1, sys, inp);
  67.       case (3)
  68.         [y, t] = stepimp(1, sys, inp, tstop);
  69.       case (4)
  70.         [y, t] = stepimp(1, sys, inp, tstop, n);
  71.     endswitch
  72.   endif
  73.  
  74. endfunction
  75.