square

Generate a square wave with range [-1,1] and period 2*pi.

Syntax

s = square(t)

s = square(t, duty)

Inputs

t
The times at which to generate the signal.
Dimension: vector
duty
The percentage of time for which the wave is at +1. (default: 50)
Dimension: scalar

Outputs

s
The square wave.

Example

Plot five periods of a square wave.

t = [0:0.01:2]*(2*pi);
s = square(t);
plot (t, s);
xlabel('time');
ylabel('amplitude');
Figure 1. square figure 1


Comments