home *** CD-ROM | disk | FTP | other *** search
- //----------------------------------------------------------------------------------
- //
- // ssdelete
- //
- // Syntax: A=ssdelete(a,b,c,d,e,f,g)
- //
- // This routine removes inputs, outputs, and state from a state-space system.
- //
- // Calling this routine as A=ssdelete(a,b,c,d,input,outputs) will remove the
- // specified inputs and outputs from the system. The vectors inputs and
- // outputs contain the indices into the system inputs and outputs.
- //
- // Calling the routine as A=ssdelete(a,b,c,d,inputs,outputs,states) will
- // also return a state-space model with the specified inputs, outputs, and
- // states removed from the system.
- //
- // The results are returned in a list:
- // A.ad = selected A matrix
- // A.bd = selected B matrix
- // A.cd = selected C matrix
- // A.dd = selected D matrix
- //
- // Copyright (C), by Jeffrey B. Layton, 1994
- // Version JBL 940504
- //----------------------------------------------------------------------------------
-
- rfile abcdchk
-
- ssdelete = function(a,b,c,d,e,f,g)
- {
- local(inputs,outputs,states,msg,estr,narg,ad,bd,cd,dd)
-
- // Count number of input arguments
- narg=0;
- if (exist(a)) {narg=narg+1;}
- if (exist(b)) {narg=narg+1;}
- if (exist(c)) {narg=narg+1;}
- if (exist(d)) {narg=narg+1;}
- if (exist(e)) {narg=narg+1;}
- if (exist(f)) {narg=narg+1;}
- if (exist(g)) {narg=narg+1;}
-
- // Check a,b,c,d system to be sure it is valid
- msg="";
- msg=abcdchk(a,b,c,d);
- if (msg != "") {
- estr="SSSELECT: "+msg;
- error(estr);
- }
-
- // Create vectors describing new inputs, outputs, and states
- if (narg == 6) {
- inputs=e;
- outputs=f;
- states=[];
- }
- if (narg == 7) {
- inputs=e;
- outputs=f;
- states=g;
- }
-
- // Remove the specified inputs,outputs and states
- ad=a;
- bd=b;
- cd=c;
- dd=d;
-
- // Remove specified state cols
- ad=ad[;complement(states, 1:ad.nc)];
- cd=cd[;complement(states, 1:cd.nc)];
- // Remove specified state rows
- ad=ad[complement(states, 1:ad.nr);];
- bd=bd[complement(states, 1:bd.nr);];
- // Remove specified inputs
- bd=bd[;complement(inputs, 1:bd.nc)];
- dd=dd[;complement(inputs, 1:dd.nc)];
- // Remove speicifed outputs
- cd=cd[complement(outputs, 1:cd.nr);];
- dd=dd[complement(outputs, 1:dd.nr);];
-
-
- return << ad=ad; bd=bd; cd=cd; dd=dd >>
- };
-