gensig
Create periodic signals for simulating system response.
📝Syntax
[u, t] = gensig(type, tau)
[u, t] = gensig(type, tau, Tf)
[u, t] = gensig(type, tau, Tf, Ts)
📥Input Arguments
Parameter Description
type Type of periodic signal: 'cos', 'tan', 'sin', 'pulse', 'square'
tau Period: positive scalar
Tf Duration: positive scalar or 5*tau (default)
Ts positive scalar or tau/64 (default)
📤Output Arguments
Parameter Description
u Generated signal: column vector.
t Time vector: column vector.
📄Description

The functiongensig(type, tau) creates a periodic signal with unit amplitude, characterized by the specified type and period.

The resulting signal, denoted asu, and its corresponding time vector,t, can be utilized for simulating the time response of a single-input dynamic system usinglsim.

For multi-input systems, you can generate signals by making repeated calls togensig and then assemble the resultingu vectors into a matrix. When simulating a dynamic system model withu and t, note that the software interprets the time vectort with units based on the TimeUnit property of the model.

To generate a signal with a specific duration Tf, use[u, t] = gensig(type, tau, Tf).

The time vector t spans from 0 toTf in increments of tau/64.

For a signal with a defined sample time Ts, employ[u, t] = gensig(type, tau, Tf, Ts).

In this case, the time vector t ranges from 0 toTf in increments of Ts.

This syntax is particularly useful for generating signals tailored for discrete-time model simulations, whereTs corresponds to the sample time of the model.

💡Examples
f = figure();
tau = 3;
Tf = 6;
Ts = 0.1;

subplot(3, 2, 1)
[u,t] = gensig("sine",tau,Tf,Ts);
plot(t, u)
title('sine')

subplot(3, 2, 2)
[u,t] = gensig("square",tau,Tf,Ts);
plot(t, u)
title('square')

subplot(3, 2, 3)
[u,t] = gensig("cos",tau,Tf,Ts);
plot(t, u)
title('cosine')

subplot(3, 2, 4)
[u,t] = gensig("sin",tau,Tf,Ts);
plot(t, u)
title('sine')

subplot(3, 2, 5)
[u,t] = gensig("tan",tau,Tf,Ts);
plot(t, u)
title('tan')
Example illustration
🔗See Also
lsim
🕔Version History
Version Description
1.0.0 initial version
Edit this page on GitHub