home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / languages / rlab1_23a / CTB / obsv < prev    next >
Text File  |  1995-11-14  |  730b  |  37 lines

  1. //--------------------------------------------------------------
  2. //
  3. // obsv
  4. //
  5. // Syntax: ob=obsv(a,c)
  6. //
  7. // This routines forms the observability matrix.
  8. // ob=obsv(a,c,) returns the observability matrix.
  9. // ob = [c; ca; ca^2; ...]
  10. //
  11. // Copyright (C), by Jeffrey B. Layton, 1994
  12. // Version JBL 940919
  13. //--------------------------------------------------------------
  14.  
  15. obsv = function(a,c)
  16. {
  17.    local(nargs,D,i,ob)
  18.  
  19. // Count number of inpute arguments
  20.    nargs=0;
  21.    if (exist(a)) {nargs=nargs+1;}
  22.    if (exist(c)) {nargs=nargs+1;}
  23.  
  24.    if (nargs != 2) {
  25.        error("OBSV: Wrong number of input arguments.");
  26.    }
  27.  
  28.    ob=c;
  29.    D=ones(a.nr,a.nc);
  30.    for (i in 1:a.nc-1) {
  31.         D=D*a;
  32.         ob=[ob;c*D];
  33.    }
  34.  
  35.    return ob
  36. };
  37.