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

  1. # Copyright (C) 1996 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 [csys,Acd,Ccd] = syscont(sys)
  18. # function [csys,Acd,Ccd] = syscont(sys)
  19. # returns csys = sys with discrete states./utputs omitted.
  20. #
  21. # inputs: sys is a system data structure
  22. # outputs: csys is the purely continuous input/output connections of
  23. #               sys
  24. #          Acd, Ccd: connections from discrete states to continuous states,
  25. #               discrete states to continuous outputs, respectively.
  26. #
  27. # returns csys empty if no continuous/continous path exists
  28.  
  29. # Written by John Ingram August 1996
  30.  
  31.   save_val = implicit_str_to_num_ok;    # save for later
  32.   save_empty = empty_list_elements_ok;
  33.   empty_list_elements_ok = implicit_str_to_num_ok = 1;
  34.  
  35.   if (nargin != 1)
  36.     usage("[csys,Acd,Ccd,Dcd] = syscont(sys)");
  37.   elseif (!is_struct(sys))
  38.     error("sys must be in system data structure form");
  39.   endif
  40.  
  41.   sys = sysupdate(sys,"ss");
  42.   [n_tot,st_c,st_d,y_c,y_d] = syscont_disc(sys);    # get ranges
  43.  
  44.   # assume there's nothing there; build partitions as appropriate
  45.   Acc = Acd = Bcc = Ccc = Ccd = Dcc = [];
  46.  
  47.   if(isempty(st_c) & isempty(y_c))
  48.     error("syscont: expecting continous states and/or continous outputs");
  49.   elseif (isempty(st_c))
  50.     warning("syscont: no continuous states");
  51.   elseif(isempty(y_c))
  52.     warning("syscont: no continuous outputs");
  53.   endif
  54.  
  55.   [sys_a, sys_b, sys_c, sys_d ] = sys2ss(sys);
  56.   [sys_stname, sys_inname, sys_outname] = sysgetsignals(sys);
  57.   [sys_n, sys_nz, sys_m, sys_p] = sysdimensions(sys);
  58.   if(!isempty(st_c))
  59.     Acc = sys_a(st_c,st_c);
  60.     stname = sys_stname(st_c);
  61.     Bcc = sys_b(st_c,:);
  62.     Ccc = sys_c(y_c,st_c);
  63.     Acd = sys_a(st_c,st_d);
  64.   else
  65.     stname=[];
  66.   endif
  67.   outname = sys_outname(y_c);
  68.   Dcc = sys_d(y_c,:);
  69.   Ccd = sys_c(y_c,st_d);
  70.   inname = sys_inname;
  71.   
  72.   csys = ss2sys(Acc,Bcc,Ccc,Dcc,0,sys_n,0,stname,inname,outname);
  73.  
  74.   implicit_str_to_num_ok = save_val;    # restore value
  75.   empty_list_elements_ok = save_empty;
  76.  
  77. endfunction
  78.