%% Generate Signal with Specified Sample Time
% If you do not specify a time step (sample time), gensig defaults to 64 samples per period, or Ts = tau/64. When you want to simulate a discrete-time model with lsim, the time step must equal the sample time of the model. Provide gensig with this sample time to generate a suitable signal. For example, generate a sine wave for simulating a discrete-time dynamic system model with a 0.1 s sample time.

tau = 3;
Tf = 6;
Ts = 0.1;
[u,t] = gensig("sine",tau,Tf,Ts);

%
% Simulate the model response to the generated signal.

sys = zpk([],[-0.1,-0.5],1,Ts);
lsim(sys,u,t,Ts)

%
% Copyright 2020 The MathWorks, Inc.