#include
#define NUMX 4 // number of states
#define NUMU 1 // number of inputs
#define NUMY 1 // number of outputs
int main() {
double A[NUMX][NUMX] = {{-4.12, -17.4, -30.8, -60},
{1, 0, 0, 0},
{0, 1, 0, 0},
{0, 0, 1, 0}},
B[NUMX][NUMU] = {1, 0, 0, 0},
C[NUMY][NUMX] = {4, 8.4, 30.78, 60},
D[NUMY][NUMU] = {0};
class CControl sys;
int nnum, nden;
sys.model("ss", A, B, C, D);
nnum = sys.size('n');
nden = sys.size('d');
array double num[nnum], den[nden];
printf("\nThe system is created with SS model\n");
printf("Transfer function parameters obtained by printtf() member function.\n");
sys.printtf();
printf("\n\n");
/* get the coefficients of numerator and denominator */
sys.tfdata(num, den);
printf("Transfer function parameters obtained by tfdata() member function.\n");
printf("num = %f\nden = %f\n", num, den);
int nz, np;
nz = sys.size('z');
np = sys.size('p');
array double complex z[nz], p[np];
double k;
printf("ZPK information obtained by printzpk() member function.\n");
sys.printzpk();
printf("\n\n");
/* get the zeros and poles of the system */
sys.zpkdata(z, p, &k);
printf("ZPK information obtained by zpkdata() member function.\n");
printf("z = %f\n p = %f\n k = %f\n", z, p, k);
return 0;
}