Square Wave

A square wave is a signal which oscillates between only two possible amplitude values. There is a function in Matlab for synthesizing a square wave which oscillates between \pm 1. The basic syntax for using the function is the following:

[y] = square(2 * pi * f * t,duty)

Input Variables:

f – frequency of the signal (scalar in Hz)

t – an array of time samples for a signal.

duty – for duty cycle. The percentage of a cycle which is positive from [0,100].

Output Variable:

y – an array containing a square-wave signal.

Further documentation for the function is available here.

Now let’s look at another test signal called a sawtooth wave.