home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / SCRIPTS.ZIP / scripts.fat / control / step.m < prev    next >
Text File  |  1999-12-24  |  3KB  |  107 lines

  1. ## Copyright (C) 1996 Auburn University.  All Rights Reserved.
  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. ## 
  10. ## Octave is distributed in the hope that it will be useful, but WITHOUT 
  11. ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  12. ## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
  13. ## for more details.
  14. ## 
  15. ## You should have received a copy of the GNU General Public License 
  16. ## along with Octave; see the file COPYING.  If not, write to the Free 
  17. ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. 
  18.  
  19. ## -*- texinfo -*-
  20. ## @deftypefn {Function File } {[@var{y}, @var{t}] =} impulse (@var{sys}@{, @var{inp},@var{tstop}, @var{n}@})
  21. ## Step response for a linear system.
  22. ##        The system can be discrete or multivariable (or both).
  23. ## If no output arguments are specified, @code{impulse}
  24. ##  produces a plot or the step response data for system @var{sys}.
  25. ## 
  26. ## @strong{Inputs}
  27. ## @table @var
  28. ## @item sys
  29. ## System data structure.
  30. ## @item inp
  31. ## Index of input being excited
  32. ## @item tstop
  33. ##  The argument @var{tstop} (scalar value) denotes the time when the
  34. ##  simulation should end. 
  35. ## @item n
  36. ## the number of data values.
  37. ## 
  38. ##  Both parameters @var{tstop} and @var{n} can be omitted and will be
  39. ##  computed from the eigenvalues of the A-Matrix.
  40. ## @end table
  41. ## @strong{Outputs}
  42. ## @var{y}, @var{t}: impulse response
  43. ## 
  44. ## When invoked with the output paramter y the plot is not displayed.  
  45. ## @end deftypefn
  46.  
  47. ## See also:  impulse, stepimp
  48.  
  49. ## step: Step response for a linear system.
  50. ##       The system can be discrete or multivariable (or both).
  51. ##
  52. ## [y, t] = step(sys[, inp, tstop, n])
  53. ## Produces a plot or the step response data for system sys.
  54. ##
  55. ## The argument tstop (scalar value) denotes the time when the
  56. ## simulation should end. The Parameter n is the number of data values.
  57. ## Both parameters tstop and n can be ommitted and will be
  58. ## computed from the eigenvalues of the A-Matrix.
  59. ##
  60. ## When the step function is invoked with the output parameter y
  61. ## a plot is not displayed.
  62. ##
  63. ## See also: impulse, stepimp
  64.  
  65. function [y, t] = step (sys, inp, tstop, n)
  66. ## Written by Kai P. Mueller September 30, 1997
  67. ## based on lsim.m of Scottedward Hodel
  68. ## modified by
  69.  
  70.   if((nargin < 1) || (nargin > 4))
  71.     usage("[y, u] = step(sys[, inp, tstop, n])");
  72.   endif
  73.  
  74.   if(nargout > 2)
  75.     usage("[y, u] = step(sys[, inp, tstop, n])");
  76.   endif
  77.  
  78.   if(!is_struct(sys))
  79.     error("step: sys must be a system data structure.");
  80.   endif
  81.  
  82.   if (nargout == 0)
  83.     switch (nargin)
  84.       case (1)
  85.         stepimp(1, sys);
  86.       case (2)
  87.         stepimp(1, sys, inp);
  88.       case (3)
  89.         stepimp(1, sys, inp, tstop);
  90.       case (4)
  91.         stepimp(1, sys, inp, tstop, n);
  92.     endswitch
  93.   else
  94.     switch (nargin)
  95.       case (1)
  96.         [y, t] = stepimp(1, sys);
  97.       case (2)
  98.         [y, t] = stepimp(1, sys, inp);
  99.       case (3)
  100.         [y, t] = stepimp(1, sys, inp, tstop);
  101.       case (4)
  102.         [y, t] = stepimp(1, sys, inp, tstop, n);
  103.     endswitch
  104.   endif
  105.  
  106. endfunction
  107.