Generate test input signals for lsim
[u,t] = gensig(type,tau)
[u,t] = gensig(type,tau,Tf,Ts)
gensig returns a vector t of time samples and the vector u of signal values at these samples. All generated signals have unit amplitude.
You can feed the outputs u and t directly to lsim and simulate the response of a single-input linear system to the specified signal. Since t is uniquely determined by Tf and Ts, you can also generate inputs for multi-input systems by repeated calls to gensig.
Generate a square wave with period 5 seconds, duration 30 seconds, and sampling every 0.1 second.
[u,t] = gensig('square',5,30,0.1)
Plot the resulting signal.
plot(t,u) axis([0 30 -1 2])