Exemple #1
0
        private void ToStateSpace(double[] num, double[] den)
        {
            double a = den[0];

            for (int i = 0; i < num.Length; i++)
            {
                num[i] = num[i] / a;
            }
            for (int i = 0; i < den.Length; i++)
            {
                den[i] = den[i] / a;
            }

            int    len = den.Length - 1;
            Matrix A   = new Matrix(len, len, 0d);

            for (int i = 0; i < len; i++)
            {
                A[len - 1, i] = -den[den.Length - 1 - i];
            }
            int ones = len - 1;

            for (int i = 0; i < ones; i++)
            {
                A[i, i + 1] = 1d;
            }
            Vector B = new Vector(len, 0d);

            B[len - 1] = 1d;
            Vector C = new Vector(len, 0d);

            for (int i = num.Length - 1; i >= 0; i--)
            {
                C[num.Length - 1 - i] = num[i];
            }
            double D = 0d;

            StateSpace = new StateSpaceModel(A, B, C, D);
        }
Exemple #2
0
 public static Vector ToOutput(StateSpaceModel stateSpace, double initialOutput)
 {
     return(ToOutput(stateSpace.C, initialOutput));
 }