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

  1. # Copyright (C) 1996,1998 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 h2gain = h2norm(sys)
  18.   # Usage: h2gain = h2norm(sys)
  19.   #
  20.   # Computes the H2 norm system data structure (continuous time only)
  21.   # sys = system data structure [see ss2sys()]
  22.   # returns h2gain = Inf if system is unstable
  23.   #
  24.   # Reference:
  25.   # Doyle, Glover, Khargonekar, Francis, "State Space Solutions to Standard
  26.   # H2 and Hinf Control Problems", IEEE TAC August 1989
  27.   #
  28.  
  29.   # A. S. Hodel Aug 1995
  30.   # updated for system data structure by John Ingram November 1996
  31.  
  32.   if((nargin != 1))
  33.     usage("h2gain = h2norm(sys)");
  34.   elseif(!is_struct(sys))
  35.     error("Sys must be in system data structure");
  36.   end
  37.   dflg = is_digital(sys);
  38.  
  39.   if(!is_stable(sys))
  40.     warning("h2norm: unstable input system; returning Inf");
  41.     h2gain = Inf;
  42.   else
  43.     # compute gain
  44.     [a,b,c,d] = sys2ss(sys);
  45.     if(dflg)
  46.       M = dlyap(a,b*b');
  47.     else
  48.       M = lyap (a,b*b');
  49.     endif
  50.     if( min(real(eig(M))) < 0)
  51.       error("h2norm: grammian not >= 0 (lightly damped modes?)")
  52.     endif
  53.  
  54.     h2gain = sqrt(trace(d'*d + c*M*c'));
  55.   endif
  56. endfunction
  57.