lsim Computes the time response of a Linear system described by: [REMOVE_ME]x=Ax+Bu[REMOVEME2]
[REMOVE_ME]y=Cx+Du[REMOVEME2]
to the input time history u.
lsim(sys, u, t, x0)
Arguments
sys: An LTI system of tf, ss and zpk class
u: A row vector for single input systems. The input u must have as many rows as there are inputs in the system. Each column of U corresponds to a new time point. u could be generated using a signal generator like gensig
t: time vector which must be regularly spaced. e.g. seq(0,4,0.1)
x0: a vector of initial conditions with as many rows as the rows of a
Returns
Returns a list of two matrices, x and y. The x values are returned from ltitr
call.
Description
lsim Computes the time response of a Linear system described by:
x=Ax+Buy=Cx+Du
to the input time history u.
Details
lsim(sys, u, t) provides the time history of the linear system with zero-initial conditions.
lsim(sys, u, t, x0) provides the time history of the linear system with initial conditions. If the linear system is represented as a model of tf or zpk
it is first converted to state-space before linear simulation is performed. This function depends on c2d and ltitr
Examples
signal <- gensig('square',4,10,0.1)H <- tf(c(2,5,1),c(1,2,3))response <- lsim(H, signal$u, signal$t)plot(signal$t, response$y, type ="l", main ="Linear Simulation Response", col ="blue")lines(signal$t, signal$u, type ="l", col ="grey")grid(5,5, col ="lightgray")## Not run: based on example at: https://www.mathworks.com/help/ident/ref/lsim.html ## Not run: MIMO system response A <- rbind(c(0,1), c(-25,-4)); B <- rbind(c(1,1), c(0,1))C <- rbind(c(1,0), c(0,1)); D <- rbind(c(0,0), c(0,0))response <- lsim(ss(A,B,C,D), cbind(signal$u, signal$u), signal$t)plot(signal$t, response$y[1,], type ="l", main ="Linear Simulation Response", col ="blue"); grid(7,7)plot(signal$t, response$y[2,], type ="l",main ="Linear Simulation Response", col ="blue"); grid(7,7)