home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / r / rlab / CTB / ssdelete < prev    next >
Encoding:
Text File  |  1995-11-15  |  2.2 KB  |  85 lines

  1. //----------------------------------------------------------------------------------
  2. //
  3. // ssdelete
  4. //
  5. // Syntax: A=ssdelete(a,b,c,d,e,f,g)
  6. //
  7. // This routine removes inputs, outputs, and state from a state-space system.
  8. //
  9. // Calling this routine as A=ssdelete(a,b,c,d,input,outputs) will remove the
  10. // specified inputs and outputs from the system. The vectors inputs and
  11. // outputs contain the indices into the system inputs and outputs.
  12. //
  13. // Calling the routine as A=ssdelete(a,b,c,d,inputs,outputs,states) will
  14. // also return a state-space model with the specified inputs, outputs, and
  15. // states removed from the system.
  16. //
  17. //      The results are returned in a list:
  18. //      A.ad = selected A matrix
  19. //      A.bd = selected B matrix
  20. //      A.cd = selected C matrix
  21. //      A.dd = selected D matrix
  22. //
  23. // Copyright (C), by Jeffrey B. Layton, 1994
  24. // Version JBL 940504
  25. //----------------------------------------------------------------------------------
  26.  
  27. rfile abcdchk
  28.  
  29. ssdelete = function(a,b,c,d,e,f,g)
  30. {
  31.    local(inputs,outputs,states,msg,estr,narg,ad,bd,cd,dd)
  32.  
  33. // Count number of input arguments
  34.    narg=0;
  35.    if (exist(a)) {narg=narg+1;}
  36.    if (exist(b)) {narg=narg+1;}
  37.    if (exist(c)) {narg=narg+1;}
  38.    if (exist(d)) {narg=narg+1;}
  39.    if (exist(e)) {narg=narg+1;}
  40.    if (exist(f)) {narg=narg+1;}
  41.    if (exist(g)) {narg=narg+1;}
  42.  
  43. // Check a,b,c,d system to be sure it is valid
  44.    msg="";
  45.    msg=abcdchk(a,b,c,d);
  46.    if (msg != "") {
  47.        estr="SSSELECT: "+msg;
  48.        error(estr);
  49.    }
  50.  
  51. // Create vectors describing new inputs, outputs, and states
  52.    if (narg == 6) {
  53.        inputs=e;
  54.        outputs=f;
  55.        states=[];
  56.    }
  57.    if (narg == 7) {
  58.        inputs=e;
  59.        outputs=f;
  60.        states=g;
  61.    }
  62.  
  63. // Remove the specified inputs,outputs and states
  64.    ad=a;
  65.    bd=b;
  66.    cd=c;
  67.    dd=d;
  68.  
  69. // Remove specified state cols
  70.    ad=ad[;complement(states, 1:ad.nc)];
  71.    cd=cd[;complement(states, 1:cd.nc)];
  72. // Remove specified state rows
  73.    ad=ad[complement(states, 1:ad.nr);];
  74.    bd=bd[complement(states, 1:bd.nr);];
  75. // Remove specified inputs
  76.    bd=bd[;complement(inputs, 1:bd.nc)];
  77.    dd=dd[;complement(inputs, 1:dd.nc)];
  78. // Remove speicifed outputs
  79.    cd=cd[complement(outputs, 1:cd.nr);];
  80.    dd=dd[complement(outputs, 1:dd.nr);];
  81.  
  82.  
  83.    return << ad=ad; bd=bd; cd=cd; dd=dd >>
  84. };
  85.