home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / SCRIPTS.ZIP / scripts / control / impulse.m < prev    next >
Encoding:
Text File  |  1999-12-15  |  2.6 KB  |  90 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. ## Impulse 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 impulse 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. ## @end deftypefn
  44.  
  45. ## See also:  step, stepimp
  46.  
  47. function [y, t] = impulse (sys, inp, tstop, n)
  48.  
  49. ## Written by Kai P. Mueller October 2, 1997
  50. ## based on lsim.m of Scottedward Hodel
  51. ## modified by
  52.  
  53.   if((nargin < 1) || (nargin > 4))
  54.     usage("[y, u] = impulse(sys[, inp, tstop, n])");
  55.   endif
  56.  
  57.   if(nargout > 2)
  58.     usage("[y, u] = impulse(sys[, inp, tstop, n])");
  59.   endif
  60.  
  61.   if(!is_struct(sys))
  62.     error("impulse: sys must be a system data structure.");
  63.   endif
  64.  
  65.   if (nargout == 0)
  66.     switch (nargin)
  67.       case (1)
  68.         stepimp(2, sys);
  69.       case (2)
  70.         stepimp(2, sys, inp);
  71.       case (3)
  72.         stepimp(2, sys, inp, tstop);
  73.       case (4)
  74.         stepimp(2, sys, inp, tstop, n);
  75.     endswitch
  76.   else
  77.     switch (nargin)
  78.       case (1)
  79.         [y, t] = stepimp(2, sys);
  80.       case (2)
  81.         [y, t] = stepimp(2, sys, inp);
  82.       case (3)
  83.         [y, t] = stepimp(2, sys, inp, tstop);
  84.       case (4)
  85.         [y, t] = stepimp(2, sys, inp, tstop, n);
  86.     endswitch
  87.   endif
  88.  
  89. endfunction
  90.