home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21fb.zip / octave / SCRIPTS.ZIP / scripts / control / h2norm.m < prev    next >
Encoding:
Text File  |  1999-12-15  |  1.8 KB  |  58 lines

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