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

  1. # Copyright (C) 1997 Kai P. Mueller
  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 outsys = ord2(nfreq, damp, gain)
  18.   # function outsys = ord2(nfreq, damp[, gain])
  19.   # Creates a continuous 2nd order system with parameters:
  20.   #
  21.   #      nfreq:   natural frequency [Hz]. (not in rad/s)
  22.   #      damp:    damping coefficient
  23.   #      gain:    dc-gain
  24.   #               This is steady state value only for damp > 0.
  25.   #               gain is assumed to be 1.0 if ommitted.
  26.   #
  27.   #      The system has representation with w = 2 * pi * nfreq:
  28.   #
  29.   #          /                                        \
  30.   #          | / -2w*damp -w \  / w \                 |
  31.   #      G = | |             |, |   |, [ 0  gain ], 0 |
  32.   #          | \   w       0 /  \ 0 /                 |
  33.   #          \                                        /
  34.   #
  35.   # See also: jet707 (MIMO example, Boeing 707-321 aircraft model)
  36.  
  37.   # Written by Kai P. Mueller September 28, 1997
  38.   # Updates
  39.  
  40.   if(nargin != 2 & nargin != 3)
  41.     usage("outsys = ord2(nfreq, damp[, gain])")
  42.   endif
  43.   if (nargout > 1)
  44.     usage("outsys = ord2(nfreq, damp[, gain])")
  45.   endif
  46.   if (nargin == 2)
  47.     gain = 1.0;
  48.   endif
  49.  
  50.   w = 2.0 * pi * nfreq;
  51.   outsys = ss2sys([-2.0*w*damp, -w; w, 0], [w; 0], [0, gain]);
  52. endfunction
  53.