How do I make a user-defined square wave generator in simulink model?

I want to make a user defined square wave generator for simulink model( instead of using pulse generator).
But I don't know which formula should I use. I am asking for help.
Thanks in advance.

Answers (1)

Perhaps you can try this one:
tau = 20; % period of the square wave
Ts = tau/(2^10); % 2^10 samples per period
[u, t] = gensig('square', tau, 2*tau, Ts);
plot(t, u, 'linewidth', 1.5), grid, ylim([-1 2])

1 Comment

Actually, I want to make it for simulink model. And this way doesn't work!

Sign in to comment.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Asked:

on 29 Aug 2022

Commented:

on 29 Aug 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!