MATLAB Answers

Generating a square wave

4 views (last 30 days)
Marcos García
Marcos García on 17 Mar 2017
Answered: Hildo on 18 Mar 2017
Hi...
I would like to know how to generate a square wave in Simulink with variable frequency, that is, I should be able to change the frequency of that square wave externally. The square wave generator from the Simulink library is not useful for my purpose.
Regards.

  0 Comments

Sign in to comment.

Accepted Answer

Hildo
Hildo on 18 Mar 2017
  1. Use the block "clock" that output to you the simulation time;
  2. Get the rest of the division of this time by your period https://www.mathworks.com/matlabcentral/answers/7260-how-to-get-the-remainder-of-a-division-in-simulink;
  3. Use the "switch block" to check if is the first part (HIGH level) of the period (output 0 or 1).

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products