home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 4
/
DATAFILE_PDCD4.iso
/
languages
/
rlab1_23a
/
CTB
/
ssselect
< prev
next >
Wrap
Text File
|
1995-11-14
|
2KB
|
73 lines
//----------------------------------------------------------------------------------
//
// ssselect
//
// Syntax: A=ssselect(a,b,c,d,inputs,outputs,states)
//
// This routine extracts a subsystem from a larger system. Calling this
// routine as A=ssselect(a,b,c,d,inputs,outputs) will return the state
// space subsystem with the specified inputs and outputs (vectors that
// are input to the routine). Notice that the vectors input and output
// contain indices into the system inputs and outputs.
//
// Calling the routine as A=ssselect(a,b,c,d,inputs,outputs,states) will return
// the state space subsystem with the specified inputs, outputs, and states.
// and states.
//
// Note: The matrices ae, be, ce, and de are returned in a list.
//
// A.ae = ae matrix.
// A.be = be matrix.
// A.ce = ce matrix.
// A.de = de matrix.
//
// Copyright (C), by Jeffrey B. Layton, 1994
// Version JBL 940405
//----------------------------------------------------------------------------------
rfile abcdchk
rfile isempty
ssselect = function(a,b,c,d,inputs,outputs,states)
{
local(narg,msg,estr,innew,outnew,statenew,ae,be,ce,de)
// 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(inputs)) {narg=narg+1;}
if (exist(outputs)) {narg=narg+1;}
if (exist(states)) {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) {
innew=inputs;
outnew=outputs;
statenew=1:a.nr;
}
if (narg == 7) {
innew=inputs;
outnew=outputs;
statenew=states;
}
// Select system
ae=a[statenew;statenew];
be=b[statenew;outnew];
ce=c[outnew;statenew];
de=d[outnew;innew];
return << ae=ae; be=be; ce=ce; de=de >>
};