/* -*- MaTX -*- * * NAME * dlsim() - Simulation of discrete-time linear systems * * SYNOPSIS * {Y,X} = dlsim(A,B,C,D,U) * Matrix Y, X; * Matrix A,B,C,D; * Matrix U; * * {Y,X} = dlsim(A,B,C,D,U,x0) * Matrix Y, X; * Matrix A,B,C,D; * Matrix U; * Matrix x0; * * DESCRIPTION * dlsim() calculates the time response of the discrete-time system: * * x[n+1] = Ax[n] + Bu[n] * y[n] = Cx[n] + Du[n] * * to the input sequence U, where Rows(U) = Rows(u). Each column of * U corresponds to a time point. * * dlsim() returns the Rows(y)-by-Cols(U) output-history matrix Y, * and the state-history matrix X. * * dlsim(..., x0) uses x0 to specify the initial conditions. * * SEE ALSO * lsim */ Func List dlsim(A, B, C, D, U, x0_, ...) Matrix A, B, C, D, x0_; Matrix U; { String msg; Matrix X, Y, x0; error(nargchk(5, 6, nargs, "dlsim")); if (length((msg = abcdchk(A, B, C, D))) > 0) { error("dlsim(): " + msg); } if (nargs == 5) { x0 = Z(Rows(A),1); } else { x0 = x0_; } X = ltitr(A, B, U, x0); Y = C*X + D*U; return {Y,X}; }