Redirect lsim output to a vector
-
20-12-2019 - |
Question
I have been using this function to simulate output of a linear system
lsim(sys, [ ones(1,40/0.04+1) ], 0:0.05:50 )
It have been very useful so far, but now I want to manipulate the output data before plotting it. I am been looking for a function like lsim but that redirects the output to a vector, but I couldnt find it.
Solution
I have just found the way. From matlab help
When invoked with left-hand arguments,
[y,t] = lsim(sys,u,t) [y,t,x] = lsim(sys,u,t) % for state-space models only [y,t,x] = lsim(sys,u,t,x0) % with initial state
return the output response y, the time vector t used for simulation, and the state trajectories x (for state-space models only). No plot is drawn on the screen. The matrix y has as many rows as time samples (length(t)) and as many columns as system outputs. The same holds for x with "outputs" replaced by states.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow