home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / SCRIPTS.ZIP / scripts.fat / control / ltifr.m < prev    next >
Text File  |  1999-12-24  |  3KB  |  96 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{out} =} ltifr (@var{A}, @var{B}, @var{w})
  21. ## @deftypefnx {Function File } {@var{out} =} ltifr (@var{sys}, @var{w})
  22. ## Linear time invariant frequency response of single input systems
  23. ## @strong{Inputs}
  24. ## @table @var
  25. ## @item A, B
  26. ## coefficient matrices of @math{dx/dt = A x + B u}
  27. ## @item sys
  28. ##  system data structure
  29. ## @item w
  30. ##  vector of frequencies
  31. ## @end table
  32. ## @strong{Outputs}
  33. ## @var{out}
  34. ## @example
  35. ##                            -1
  36. ##             G(s) = (jw I-A) B
  37. ## @end example
  38. ## for complex frequencies @math{s = jw}.
  39. ## @end deftypefn
  40.  
  41. function out = ltifr (a, b, w)
  42.  
  43.   ## R. B. Tenison, D. Clem, A. S. Hodel, July 1995
  44.   ## updated by John Ingram August 1996 for system format
  45.   
  46.   if ((nargin < 2) || (nargin > 3))
  47.     error("incorrect number of input arguments");
  48.   endif
  49.  
  50.   if (nargin == 2)
  51.     sys = a;
  52.     w = b;
  53.     if(!is_struct(sys))
  54.       error("two arguments: 1st must be a system data structure");
  55.     endif
  56.  
  57.     if (!is_vec(w))
  58.       error("w must be a vector");
  59.     endif
  60.     
  61.     [nn,nz,mm,pp] = sysdimen(sys);
  62.     if(mm != 1)       error("sys has %d > 1 inputs",mm); endif
  63.  
  64.     [a,b] = sys2ss(sys);
  65.  
  66.   else  
  67.  
  68.     if (columns(a) != rows(b)),
  69.       error("ltifr:  A(%dx%d), B(%dx%d) not compatibly dimensioned", ...
  70.     rows(a), columns(a), rows(b), columns(b));
  71.     endif
  72.  
  73.     if(columns(b) != 1)
  74.       error("ltifr: b(%dx%d) must be a single column vector", ...
  75.     rows(b),columns(b));
  76.     endif
  77.   
  78.     if (!is_sqr(a))
  79.       error("ltifr:  A(%dx$d) must be square.",rows(a),columns(a))
  80.     endif
  81.  
  82.   endif
  83.  
  84.   if (!is_vec(w))
  85.     error("w must be a vector");
  86.   endif
  87.  
  88.   ey = eye(size(a));
  89.   lw = length(w);
  90.   out = ones(columns(a),lw);
  91.  
  92.   for ii=1:lw,
  93.     out(:,ii) = (w(ii)*ey-a)\b;
  94.   endfor
  95. endfunction
  96.